Topic
  • 9 replies
  • Latest Post - ‏2013-09-09T16:15:44Z by thorneven
RFTworker
RFTworker
66 Posts

Pinned topic NotMapped Objects

‏2013-08-26T20:24:40Z |

Hi,

In a HTML  table, i have one small HTML.SPAN to click, so that i will get the list if courses to select. When i recorded it recorded the clicking as below

htmlTable_0().click(atCell(atRow(atIndex(1)), 

 atColumn(atIndex(1))));

But it is not clicking when Playback.

So I used x and y coordinates as below , but still did not work:

table_htmlTable_0().click(atPoint(425,370));

When i used Test Object Inspector to see the coordinates, i selected Unmapped Objects to be shown in the Options, then i was able to see HTML.SPAN as .class , .class name and all the Properties of the image which i want to click.

How can i add the code for an unmapped object to click in RFT?

Is there a way that i can add this Not mapped Object to Object Map?

I have to click on the image to select the courses list so  i can proceed further in my scenario.

I am attaching the screen shot of the image in HTML Table which i am trying to click. please suggest me if there is any other way of doing this. thanks

 

Thanks

 

Attachments

Updated on 2013-08-26T20:26:03Z at 2013-08-26T20:26:03Z by RFTworker
  • thorneven
    thorneven
    20 Posts

    Re: NotMapped Objects

    ‏2013-08-26T21:00:17Z  

    I don't know how to get RFT to find non-mapped objects when using object maps.  I do know how to find non-mapped objects using dynamic find which doesn't require object maps.  The dynamic find has an option to search for non-mapped objects.  So I can do this for example:

    // Define cell properties I want to find.

    final Property[] TableDef = new Property[]{
                                new Property(".class","Html.TD"),
                                new Property(".id", "id_attribute_of_cell")
                                };

    // Find the cell of interest.

    TestObject[] cells = find(atDescendant(TableDef),false);

    The "false" option on the find is how one gets RFT to find non-mapped objects.

  • RFTworker
    RFTworker
    66 Posts

    Re: NotMapped Objects

    ‏2013-08-26T21:19:03Z  
    • thorneven
    • ‏2013-08-26T21:00:17Z

    I don't know how to get RFT to find non-mapped objects when using object maps.  I do know how to find non-mapped objects using dynamic find which doesn't require object maps.  The dynamic find has an option to search for non-mapped objects.  So I can do this for example:

    // Define cell properties I want to find.

    final Property[] TableDef = new Property[]{
                                new Property(".class","Html.TD"),
                                new Property(".id", "id_attribute_of_cell")
                                };

    // Find the cell of interest.

    TestObject[] cells = find(atDescendant(TableDef),false);

    The "false" option on the find is how one gets RFT to find non-mapped objects.

    Thanks for your reply,

    I have tried using the same code as below : But the script just pauses at Find....in Playback. Also how can i click on the object after i find it?

    final Property[] Coursbuton = newProperty[]{

    new Property(".class","Html.SPAN"),

    new Property(".className", "detailsRowButton lookupCustomerBtn")

    };

    //Find the cell of interest.

    TestObject[] cells = find(atDescendant(Coursbuton),false);

    System.out.println(cells);

  • thorneven
    thorneven
    20 Posts

    Re: NotMapped Objects

    ‏2013-08-27T14:24:10Z  
    • RFTworker
    • ‏2013-08-26T21:19:03Z

    Thanks for your reply,

    I have tried using the same code as below : But the script just pauses at Find....in Playback. Also how can i click on the object after i find it?

    final Property[] Coursbuton = newProperty[]{

    new Property(".class","Html.SPAN"),

    new Property(".className", "detailsRowButton lookupCustomerBtn")

    };

    //Find the cell of interest.

    TestObject[] cells = find(atDescendant(Coursbuton),false);

    System.out.println(cells);

    If a find takes a long time check your find timeout value in RFT Preferences.  Also it means (obviously?) that find is not finding your object.  I believe your problem is that you have a period prefixed to "classname".  Try removing the period.

    In order to use the click method, you have to cast the object as a GuiTestObject type which is the class that contains the click method:

    ( (GuiTestObject) cells[0] ).click();

    As you can see, cells (an array) will contain as many objects as your find found so you have to figure out which one you want.  The best way to do that is to ensure your find contains as many attribute/value pairs as is necessary to ensure the object you're trying to find is unique such that only 1 object is found.  Making objects unique is something that may have to be worked out with your web developers.

    Updated on 2013-08-27T14:24:58Z at 2013-08-27T14:24:58Z by thorneven
  • Y5QY_gerben_delange
    Y5QY_gerben_delange
    34 Posts

    Re: NotMapped Objects

    ‏2013-09-04T22:41:00Z  

    the find() method should always return. if playback 'pauses' infinitly then you have found a bug in RFT.

    I suggest you adjust the scope of your search, e.g. :

    getroottestobject().find(atDescendant(TableDef), false);

    will search all testdomains (html, net, activex, win java etc), and could take a long time, depending on your situation (number of active test domains). 

    If you narrow down the scope to just the html testdomains (which will contain the span object), you will save some time.

    public void testMain(Object[] args) {
    final Property[] tableDef = new Property[] {
    new Property(".class", "Html.TD"),
    new Property(".id", "id_attribute_of_cell") };
     
    ArrayList<DomainTestObject> htmloms = getHTMLdoms();
    for (DomainTestObject domainTestObject : htmloms) {
    GuiTestObject[] candidates = (GuiTestObject[]) domainTestObject
    .find(atDescendant(tableDef), false);
    if ((candidates != null) && (candidates.length > 0)) {
    try {
    candidates[0].click();

    break;

    } catch (Exception ignore) {
    // TODO: handle exception
    }
    }
    }
     
    }
     
    public static ArrayList<DomainTestObject> getHTMLdoms() {
    ArrayList<DomainTestObject> htmlDomList = new ArrayList<DomainTestObject>();
     
    DomainTestObject[] doms = getDomains();
    for (int i = 0; i < doms.length; i++) {
    if (doms[i].getName().equals("Html")) {
    htmlDomList.add(doms[i]);
    }
    }
     
    return htmlDomList;
    }
    Updated on 2013-09-04T22:42:20Z at 2013-09-04T22:42:20Z by Y5QY_gerben_delange
  • thorneven
    thorneven
    20 Posts

    Re: NotMapped Objects

    ‏2013-09-09T14:09:08Z  

    the find() method should always return. if playback 'pauses' infinitly then you have found a bug in RFT.

    I suggest you adjust the scope of your search, e.g. :

    getroottestobject().find(atDescendant(TableDef), false);

    will search all testdomains (html, net, activex, win java etc), and could take a long time, depending on your situation (number of active test domains). 

    If you narrow down the scope to just the html testdomains (which will contain the span object), you will save some time.

    public void testMain(Object[] args) {
    final Property[] tableDef = new Property[] {
    new Property(".class", "Html.TD"),
    new Property(".id", "id_attribute_of_cell") };
     
    ArrayList<DomainTestObject> htmloms = getHTMLdoms();
    for (DomainTestObject domainTestObject : htmloms) {
    GuiTestObject[] candidates = (GuiTestObject[]) domainTestObject
    .find(atDescendant(tableDef), false);
    if ((candidates != null) && (candidates.length > 0)) {
    try {
    candidates[0].click();

    break;

    } catch (Exception ignore) {
    // TODO: handle exception
    }
    }
    }
     
    }
     
    public static ArrayList<DomainTestObject> getHTMLdoms() {
    ArrayList<DomainTestObject> htmlDomList = new ArrayList<DomainTestObject>();
     
    DomainTestObject[] doms = getDomains();
    for (int i = 0; i < doms.length; i++) {
    if (doms[i].getName().equals("Html")) {
    htmlDomList.add(doms[i]);
    }
    }
     
    return htmlDomList;
    }

    Is it not easier to do this instead of searching for all HTML domains?

    RootTestObject root = RootTestObject.getRootTestObject();
    TestObject to = root.find(atChild(".class", "Html.HtmlBrowser",".domain","Html"));

    Then you just search for the browser of interest in a loop by looking for the browser that contains the document of interest:

    for (TestObject b : to) {

    }

  • Y5QY_gerben_delange
    Y5QY_gerben_delange
    34 Posts

    Re: NotMapped Objects

    ‏2013-09-09T15:22:34Z  
    • thorneven
    • ‏2013-09-09T14:09:08Z

    Is it not easier to do this instead of searching for all HTML domains?

    RootTestObject root = RootTestObject.getRootTestObject();
    TestObject to = root.find(atChild(".class", "Html.HtmlBrowser",".domain","Html"));

    Then you just search for the browser of interest in a loop by looking for the browser that contains the document of interest:

    for (TestObject b : to) {

    }

    Hi thorneven,

    You are correct.

    The reason I use DomainTestObjects is because when I started creating getBrowser methods a few years back, I tested the perfomance of several methods. Test results indicated that using DomainTestObjects performed about 10x better (faster) then using RootTestObject.  

    You aroused my curiosity so I just did some retesting, got a couple of interesting results I would like to share. I created two getBrowser methods:

    •  using DomainTestObject
    •  using the RootTestObject interface.

    I also used two different recognition property sets:

    1. a. atChild(".class", "Html.HtmlBrowser"));
    2. b. atChild(".class", "Html.HtmlBrowser",".domain", "Html"));

    Results 1:

    Method usingDomainTestObjects:
    Number of browser test objects found: 1
    Search took 43ms
    Method usingRootTestObject:
    Number of browser test objects found: 1
    Search took 239ms
     

    Results 2:

    Method usingDomainTestObjects:
    Number of browser test objects found: 1
    Search took 37ms
    Method usingRootTestObject:
    Number of browser test objects found: 1
    Search took 28ms
     

    I guess using .domain recognition properties wasn't available yet at the time, or I simply overlooked it.. 

    I've attached the script used for measuring performance. I will do additional some testing using other attributes like .processName in order to further optimize my low-level methods.

    Thanks,

    g

     

    Attachments

  • thorneven
    thorneven
    20 Posts

    Re: NotMapped Objects

    ‏2013-09-09T15:28:48Z  

    Hi thorneven,

    You are correct.

    The reason I use DomainTestObjects is because when I started creating getBrowser methods a few years back, I tested the perfomance of several methods. Test results indicated that using DomainTestObjects performed about 10x better (faster) then using RootTestObject.  

    You aroused my curiosity so I just did some retesting, got a couple of interesting results I would like to share. I created two getBrowser methods:

    •  using DomainTestObject
    •  using the RootTestObject interface.

    I also used two different recognition property sets:

    1. a. atChild(".class", "Html.HtmlBrowser"));
    2. b. atChild(".class", "Html.HtmlBrowser",".domain", "Html"));

    Results 1:

    Method usingDomainTestObjects:
    Number of browser test objects found: 1
    Search took 43ms
    Method usingRootTestObject:
    Number of browser test objects found: 1
    Search took 239ms
     

    Results 2:

    Method usingDomainTestObjects:
    Number of browser test objects found: 1
    Search took 37ms
    Method usingRootTestObject:
    Number of browser test objects found: 1
    Search took 28ms
     

    I guess using .domain recognition properties wasn't available yet at the time, or I simply overlooked it.. 

    I've attached the script used for measuring performance. I will do additional some testing using other attributes like .processName in order to further optimize my low-level methods.

    Thanks,

    g

     

    g - While it's interesting to see the measurements, I don't worry about sub-second differences because of factors such as having to add arbitrary sleep() statements to slow down RFT because RFT cannot reliably know when a web page is fully rendered and hence can continue looking for objects.  I have to write that code.  I found that the browser property for "ready" status (I forget the property name) is not reliable in all browsers.

    Updated on 2013-09-09T15:29:34Z at 2013-09-09T15:29:34Z by thorneven
  • Y5QY_gerben_delange
    Y5QY_gerben_delange
    34 Posts

    Re: NotMapped Objects

    ‏2013-09-09T16:07:25Z  
    • thorneven
    • ‏2013-09-09T15:28:48Z

    g - While it's interesting to see the measurements, I don't worry about sub-second differences because of factors such as having to add arbitrary sleep() statements to slow down RFT because RFT cannot reliably know when a web page is fully rendered and hence can continue looking for objects.  I have to write that code.  I found that the browser property for "ready" status (I forget the property name) is not reliable in all browsers.

    I get where you're coming from.

    The readyState property has been consistently reliable in my case; I'm using IE 8.

    There are some situations in which the state won't change even though content is changing-loading, e.g. client side scripting (java script) operations do not effect the readyState property.

    http://www.w3schools.com/jsref/prop_doc_readystate.asp

    I do care about the ms differences because my framework has been set up in such a way thta I search for browser objects several times in a test, even though the browser itself will never be closed..

    For example, my function

    FillTextField.searchAndFillField(somePropery, someValue)

    will perform the following steps:

    • Get browser object
    • Check if browser is loaded, sleep otherwise (with timeOut)
    • Find textfield
    • Fill textfield
    • unregisterAll()

    The next action might be something like ClickButton.searchAndClickButton(someProperty), which will roughly perform the same steps. 

    A typical testscript consists of dozens of these types of operations, so even ms differences can add up to seconds and minutes very rapidly.

    The reason I took this approach is because of robustness. I've had some issues with InvalidSpyMemReference exceptions. Releasing object references ASAP (unregister) resolved these problems for me.

    Regards,

    g

     

  • thorneven
    thorneven
    20 Posts

    Re: NotMapped Objects

    ‏2013-09-09T16:15:44Z  

    I get where you're coming from.

    The readyState property has been consistently reliable in my case; I'm using IE 8.

    There are some situations in which the state won't change even though content is changing-loading, e.g. client side scripting (java script) operations do not effect the readyState property.

    http://www.w3schools.com/jsref/prop_doc_readystate.asp

    I do care about the ms differences because my framework has been set up in such a way thta I search for browser objects several times in a test, even though the browser itself will never be closed..

    For example, my function

    FillTextField.searchAndFillField(somePropery, someValue)

    will perform the following steps:

    • Get browser object
    • Check if browser is loaded, sleep otherwise (with timeOut)
    • Find textfield
    • Fill textfield
    • unregisterAll()

    The next action might be something like ClickButton.searchAndClickButton(someProperty), which will roughly perform the same steps. 

    A typical testscript consists of dozens of these types of operations, so even ms differences can add up to seconds and minutes very rapidly.

    The reason I took this approach is because of robustness. I've had some issues with InvalidSpyMemReference exceptions. Releasing object references ASAP (unregister) resolved these problems for me.

    Regards,

    g

     

    I have to test several platforms (different browsers and OS's) and I have found .readyState is not reliable and especially for the reason you mention.  Our web app uses Javascript and Dojo extensively.

    And yes. my scripts spend a lot of time searching for web objects.  I find the searches are quick as long as I limit the scope of the search and code the searches to look for uniquely-identifiable objects (by .id or other HTML attributes).  That's my strategy.

    Updated on 2013-09-09T16:16:09Z at 2013-09-09T16:16:09Z by thorneven