Maximo

Maximo

Come for answers, stay for best practices. All we're missing is you.

 View Only

file selection dialog 

Thu March 26, 2020 04:42 PM

Forum question posted - 

Hi

The file selection dialog for selecting files for, say, importing, etc, appears to run outside the scope of the recorder, i.e. at the OS level. If this is true, are there any techniques available for including populating such dialogs using data from a script? A fair number of user cases involve getting data files loaded which involve selecting files from such dialogs.

 

thanks

Jeff



Response -

1)

Hi Jeff.

 

That is something we worked on after getting the customer framework on the community. We will be adding information to the community about how to do this type of testing in the near future. In the meantime, I quickly just put together some information for you. The first document (Testing Attached Documents) tells you how to actually go about the testing, what events to use, etc, and a property that needs to be added to your properties file. The second document (TestDriver and Browser updates for Attached Documents) contains the new events and methods created to do this testing. In the second document, some imports may have been missed, but the project will give you an error and you can right click and import them. 


Let me know if you need more information or any clarification after looking at these.

 

Thanks, 

Kristin

2)

Thanks!! I'll check it out and let you know. 

 

Jeff

3)

Hi Kristin,

 

About the java updates.. a couple small clarifications sought here besides imports, and a final question in general.

TestDriver.java

        browser.typeOver("file", downloadsFolder + link);   --downloadsFolder isn't declared, and it isn't obvious where it gets initialized.

Browser.java

                        if (MockUtil.isMocked() && datatype.equalsIgnoreCase("9")) -- MockUtil cannot be resolved - not sure what import will fix this - do I need to add a specific version of a Mockito jar or two to the project?

                        if(this instanceof AnywhereBrowser || isMac()) -- AnywhereBrowser cannot be resolved to a type - What jar do I need to include to import something for "AnywhereBrowser" ?

 

final question in general

If I want to test loading a data file for MIF testing etc, how can I get by the select file dialog?

 

thanks

Jeff

4)

knew there would probably be some problems when getting the info together too quickly.

 

I attached the new typeIntoField method - you can copy this over the existing one in Browser.java and ignore any problems you saw with that.

 

As for the downloads folder, you can initialize it in TestDriver.java: private String downloadsFolder = null;

 

For the last question, about MIF, I'm not sure as we don't do any automated testing at this time with MIF. Is there a different dialog other than the select file dialog that is used for attached documents? There are other applications/dialogs that also allow file selection but we have found that the code is the same for each of them. This may be the exception, but I'm not sure...

 

Thanks, 

Kristin

5)

Oh here is one note.. I said I didn't see where downloadfile was intialized - it doesn't ever seem to get the value from the properties file (I must of missed it or it wasn't in my copy) so I'm adding it myself here in TestDriver.java:

 

        uitestRootFolder = AutomationUtility.getProperty("uitest.root.folder");
        this.downloadsFolder = AutomationUtility.getProperty("uitest.downloads.folder");//need for attached docs

 

I'm not quite getting the doclinks to work - I don't know if something is missing from the Browser.java typeIntoField method - I dug into it some and its throwing an exception. I attached a screenshot of the report_results.html - below is my bin file (it also opens and closes a custom dialog before it does the doclinks):

In Browser.java : typeIntoField  when this is invoked...

 

it seems to find the element "file" (elem = [[RemoteWebDriver: firefox on WINDOWS (2b2fef19-c344-4889-abd8-25e8fb76630c)] -> id: file])

 it does a elem.sendKeys("[[RemoteWebDriver: firefox on WINDOWS (2b2fef19-c344-4889-abd8-25e8fb76630c)] -> id: file]"  ok

 

but the value comes back null here (the id comes back "file"):

                String value = elem.getAttribute("value");
                String thisid = elem.getAttribute("id");

 

 

since value is null, this code doesn't do much:

 

                else if (id.contains("file"))
                {
                    value = value.replace("\\", "/");
                    string = string.replace("\\", "/");
                    String[] fieldFilePath = value.split("/");
                    value = fieldFilePath[fieldFilePath.length - 1];
                    String[] filePath = string.split("/");
                    string = filePath[filePath.length - 1];
                }

 

Once again I might of just boffed up something far away. for example I had to use this format instead of the other in the properties file:

//uitest.downloads.folder=C:\DOCLINKS
uitest.downloads.folder=C:/doclinks.selenium/

thanks

Jeff

 

below 

/*
* Licensed Materials - Property of IBM
* 5724-U18
* (C) COPYRIGHT IBM CORP. 2014 All Rights Reserved.
* US Government Users Restricted Rights - Use, duplication or
* disclosure restricted by GSA ADP Schedule Contract with
* IBM Corp.
*/

/* IBM Interaction Recorder output file */


    "configuration": {
        "keywords":["ui", "inventory"],
        "dataInputFile":  "./testcases/RecordedExamples2/ICInput.data",
        "dataOutputFile": "./testcases/RecordedExamples2/ICGenerated.data"
    },

    "interactions": [
    {"event":"startTestStep","name":"going to do Item Consolidation stuff2"},
                {"index":0,"event":"clickMenu","id":"m7f8f3e49_ns_menu_INVENTOR_MODULE_sub_changeapp_INVENTOR_a","eventType":"click","params":["m7f8f3e49_ns_menu_INVENTOR_MODULE_a"],"comment":"Click the undefined menuitem"},
        {"index":1,"comment":"changeapp : inventor"},
                {"index":2,"event":"clickMenu","id":"m74daaf83_ns_menu_CONSOLIDA2_OPTION_a","eventType":"click","params":[],"comment":"Click the undefined menuitem"},
        {"index":3,"comment":"showdialog : Open Item Consolidation Spreadsheet"},
        {"index":0,"event":"click","id":"md0955453-pb2","comment":"Click the Cancel button in the dialog","eventType":"click"},
        {"index":1,"comment":"hidedialog : Open Item Consolidation Spreadsheet"},
        
        {"index":0,"event":"click","id":"m6a7dfd2f-img5","comment":"click m6a7dfd2f-img5","eventType":"click"},
                {"index":1,"event":"click","id":"m6a7dfd2f_tdrow_[C:1]_ttxt-lb[R:0]","comment":"Click the link for record 8100604612","eventType":"click"},
        {"index":2,"comment":"maintabchange :  Inventory"},
                {"index":3,"event":"click","id":"md5bd66d5-ti_img","comment":"click md5bd66d5-ti_img  attachments paperclip icon","eventType":"click"},
                {"index":4,"event":"clickMenu","id":"ATTACHMENTS_addnew_sub_addnewfile_a","eventType":"click","params":["ATTACHMENTS_addnew_a"],"comment":"Click the add new file sub menuitem"},
        {"index":5,"comment":"showdialog : Create a File Attachment"},
        {"event":"uploadAttachment","file":"inventor.xml"},
        {"index":0,"event":"click","id":"mbf25646-tb","comment":"click mbf25646-tb fill in name and document description","eventType":"click"},
                {"index":1,"event":"typeover","id":"mbf25646-tb","params":["testdoc01"],"comment":"change mbf25646-tb","eventType":"change"},
                {"index":2,"event":"keystroke","id":"mbf25646-tb","params":[9,"\t",false,false,false],"comment":"keydown mbf25646-tb","eventType":"keydown"},
                {"index":3,"event":"typeover","id":"mbf25646-tb2","params":["test documennt attachment01"],"comment":"change mbf25646-tb2","eventType":"change"},
                {"index":0,"event":"click","id":"m781c76a7-pb","comment":"Click the undefined button in the dialog","eventType":"click"},
        {"index":1,"comment":"hidedialog : Create a File Attachment"}
    ]

}


6)

Sorry about that again! Yes, the downloads folder needs to be initialized in TestDriver in the Driver method (around line 365):

downloadsFolder = AutomationUtility.getProperty("uitest.downloads.folder");
if(!downloadsFolder.isEmpty())
      downloadsFolder += File.separator;

 

Try adding that and re-running your test. I just tried it here using the same typeIntoField method and it worked fine, no errors on my side.

 

Thanks,

Kristin




#Maximo
#AssetandFacilitiesManagement
#MaximoEAM

Statistics
0 Favorited
8 Views
0 Files
0 Shares
0 Downloads