Topic
  • 16 replies
  • Latest Post - ‏2013-09-17T17:41:11Z by RFTworker
RFTworker
RFTworker
66 Posts

Pinned topic Get the last row count and select the check box in last row in HTML table

‏2013-09-10T20:56:05Z |

Hi,

There are 2 parts of my Scenario:

1. Input some data and get the Item Number on Page 3

2. Select the check box at the above Item Number on Page 8 and continue.

This is what I have done:

I have copied the Item Number from Page 3 and pasted it in Clipboard with a Variable.

On page 8, I am Searching(Ctrl+f) for that Item number on Web page, it's getting highlited after search, but i am not sure how to select the checkbox at that particular  Item number which is highlighted. This Item changes every time depending on how many are there before.

On Page 8 Item number is in a  HTML table, the number & rows increases based upon how many Item numbers you have. The max rows are 25 in the table.

Can anyone please let me know if  there is an easy way of doing this?  I am new to RFT and learner of Java scripting.

Thanks

  • Y5QY_gerben_delange
    Y5QY_gerben_delange
    34 Posts
    ACCEPTED ANSWER

    Re: Get the last row count and select the check box in last row in HTML table

    ‏2013-09-16T20:52:08Z  
    • RFTworker
    • ‏2013-09-16T20:40:48Z

    I missed the above new steps before, but now i have imported them to diff location and see them.

    I like the way that you make the difficulty easy by saying "good things are abt to happen".

    I have executed the new script, it is not selecting the check box , but did a big find and attached is the console and Log.

     

    Thanks for your valuable suggestions.

     

     

     

     

    ah some whitespace seems to be the problem.. changed:

     

    if (testObject.getProperty(".text").equals(itemNumber)

    to:

    if (testObject.getProperty(".text").toString().contains(itemNumber))

    see attached script. this will do the job i'm quite sure of it :)

    Attachments

  • Y5QY_gerben_delange
    Y5QY_gerben_delange
    34 Posts

    Re: Get the last row count and select the check box in last row in HTML table

    ‏2013-09-11T16:09:42Z  

    hehe nice challange.

    See code in attachment for a possible solution. I assumed that all checkboxes on page 8 have the same x coordinates.

    You need to change some object search properties, and add the code to the getItemNumberFromPage3() and goToPageEight() methods.  just read the comment lines. 

    my test output:

    68 checkboxes found :)
    getting closer! checkbox y: 77, object y: 389, difference: 312
    getting closer! checkbox y: 98, object y: 389, difference: 291
    getting closer! checkbox y: 387, object y: 389, difference: 2
    about to click checkbox! java.awt.Rectangle[x=623,y=387,width=15,height=13]
    halleluya!

    good luck,

    g

    p.s. some additional info (screenshot, object properties etc) would have be nice, so try to be more complete when you open another question thread.

    edit: improved code a little bit, attached as text file

    Attachments

    Updated on 2013-09-11T18:31:58Z at 2013-09-11T18:31:58Z by Y5QY_gerben_delange
  • RFTworker
    RFTworker
    66 Posts

    Re: Get the last row count and select the check box in last row in HTML table

    ‏2013-09-12T16:27:11Z  

    hehe nice challange.

    See code in attachment for a possible solution. I assumed that all checkboxes on page 8 have the same x coordinates.

    You need to change some object search properties, and add the code to the getItemNumberFromPage3() and goToPageEight() methods.  just read the comment lines. 

    my test output:

    68 checkboxes found :)
    getting closer! checkbox y: 77, object y: 389, difference: 312
    getting closer! checkbox y: 98, object y: 389, difference: 291
    getting closer! checkbox y: 387, object y: 389, difference: 2
    about to click checkbox! java.awt.Rectangle[x=623,y=387,width=15,height=13]
    halleluya!

    good luck,

    g

    p.s. some additional info (screenshot, object properties etc) would have be nice, so try to be more complete when you open another question thread.

    edit: improved code a little bit, attached as text file

    Please find the attached details :

    I have attached Screen shot for that page, some object propeties, and also i have attached the exported script that i have.

     

    Please let me know if you need more details. I am actually new to RFT and not sure how to code or use your code which you have mentioned.

    I will try to execute yours by manipulating with my properties but not sure 100% how i can do this

     

    Thanks for your help!

  • Y5QY_gerben_delange
    Y5QY_gerben_delange
    34 Posts

    Re: Get the last row count and select the check box in last row in HTML table

    ‏2013-09-13T12:39:05Z  
    • RFTworker
    • ‏2013-09-12T16:27:11Z

    Please find the attached details :

    I have attached Screen shot for that page, some object propeties, and also i have attached the exported script that i have.

     

    Please let me know if you need more details. I am actually new to RFT and not sure how to code or use your code which you have mentioned.

    I will try to execute yours by manipulating with my properties but not sure 100% how i can do this

     

    Thanks for your help!

    Almost there..

    Can you post the properties of the object holding the itemnumber on the last page?

     

    1. Open the object inspector tool u used to get the checkboxproperties you posted, but this time place your cursor over the itemnumer instead of the checkbox.
    2. Now press the shift key. This will pauze the object inspector and copy its contents to your clipboard (don't press Ctrl-C!!).
    3. Open notepad, hit Ctrl-V, and post resuls here.

     

    I've added my code to your script, see attachment. The only thing that needs to be changed are the search properties on line 348. Please run the script and post output here. It wont check the checkbox yet, but it will tell us if the number copy and navigation actions are still working.

     

     

  • RFTworker
    RFTworker
    66 Posts

    Re: Get the last row count and select the check box in last row in HTML table

    ‏2013-09-13T13:55:42Z  

    Almost there..

    Can you post the properties of the object holding the itemnumber on the last page?

     

    1. Open the object inspector tool u used to get the checkboxproperties you posted, but this time place your cursor over the itemnumer instead of the checkbox.
    2. Now press the shift key. This will pauze the object inspector and copy its contents to your clipboard (don't press Ctrl-C!!).
    3. Open notepad, hit Ctrl-V, and post resuls here.

     

    I've added my code to your script, see attachment. The only thing that needs to be changed are the search properties on line 348. Please run the script and post output here. It wont check the checkbox yet, but it will tell us if the number copy and navigation actions are still working.

     

     

    Thanks for providing help.

    I have attached the Object Properties of the last item number.

    Also i have executed the script and attached the script. If the export the script after the run, will you get the console details also? not sure how to give you the output.

    In the Console I saw the below message:

    item number aquired: 0000002117. Lets go to page 8 and click some checkboxes!

    we are on page 8 now. last checkbox should be on screen

    no objects found! check search props

     

    Again really Appreciate your help on this.

  • Y5QY_gerben_delange
    Y5QY_gerben_delange
    34 Posts

    Re: Get the last row count and select the check box in last row in HTML table

    ‏2013-09-13T18:27:27Z  
    • RFTworker
    • ‏2013-09-13T13:55:42Z

    Thanks for providing help.

    I have attached the Object Properties of the last item number.

    Also i have executed the script and attached the script. If the export the script after the run, will you get the console details also? not sure how to give you the output.

    In the Console I saw the below message:

    item number aquired: 0000002117. Lets go to page 8 and click some checkboxes!

    we are on page 8 now. last checkbox should be on screen

    no objects found! check search props

     

    Again really Appreciate your help on this.

    Hmm you seem to have found the properties of the entire html table.. was expecting the table row properties. Source structure should look something like this:

    // open html table tag

    <Table>

    // open table row, this is what we are looking for

    <tr>

    // open table cell

    <td>

    // cell contents (the checkbox and discription/ artikel number

     

    // close cell

    </td>

    // close row

    </tr>

    // close html table

    </table>

     

    Can you post page 8 source code so i can analyze?

     

    Ill get back to you after the weekend.

  • RFTworker
    RFTworker
    66 Posts

    Re: Get the last row count and select the check box in last row in HTML table

    ‏2013-09-13T18:46:46Z  

    Hmm you seem to have found the properties of the entire html table.. was expecting the table row properties. Source structure should look something like this:

    // open html table tag

    <Table>

    // open table row, this is what we are looking for

    <tr>

    // open table cell

    <td>

    // cell contents (the checkbox and discription/ artikel number

     

    // close cell

    </td>

    // close row

    </tr>

    // close html table

    </table>

     

    Can you post page 8 source code so i can analyze?

     

    Ill get back to you after the weekend.

    Attached is the source code for my page where i have to select the last row with rescpect to the Item number.

     

    Thank you, will be waiting for your reply...have a great weekend!

  • Y5QY_gerben_delange
    Y5QY_gerben_delange
    34 Posts

    Re: Get the last row count and select the check box in last row in HTML table

    ‏2013-09-16T10:25:40Z  
    • RFTworker
    • ‏2013-09-13T18:46:46Z

    Attached is the source code for my page where i have to select the last row with rescpect to the Item number.

     

    Thank you, will be waiting for your reply...have a great weekend!

    Hi,

    Could u run the attached script and post the results?

    This was the object I was searching for:

    .bounds:  java.awt.Rectangle[x=92,y=469,width=76,height=15]

    .class:  Html.TextNode

    .length:  11

    .text:  0000002117

    attributes:  null

    constructor:  null

    data:  0000002117

    firstChild:  null

    lastChild:  null

    length:  11

    nextSibling:  null

    nodeName:  #text

    nodeType:  3

    nodeValue:  0000002117

    previousSibling:  null

     

    It's the object closest to the checkbox you want to click which has a propertie we can use (the itemnumber .text property).

    So the script will perform the steps:

    1. Get item number from page 3.

    2. Navigate to page 8.

    3. Find the object closest to the checkbox you want to click using the itemnumber found on page 3.

    4. Find all checkbox objects on page 8.

    5. Determine which checkbox is closest to the object found in step 3, using y coordinate properties.

    6. Check the closest checkbox

     

     

     

     

     

     

     

  • RFTworker
    RFTworker
    66 Posts

    Re: Get the last row count and select the check box in last row in HTML table

    ‏2013-09-16T16:48:15Z  

    Hi,

    Could u run the attached script and post the results?

    This was the object I was searching for:

    .bounds:  java.awt.Rectangle[x=92,y=469,width=76,height=15]

    .class:  Html.TextNode

    .length:  11

    .text:  0000002117

    attributes:  null

    constructor:  null

    data:  0000002117

    firstChild:  null

    lastChild:  null

    length:  11

    nextSibling:  null

    nodeName:  #text

    nodeType:  3

    nodeValue:  0000002117

    previousSibling:  null

     

    It's the object closest to the checkbox you want to click which has a propertie we can use (the itemnumber .text property).

    So the script will perform the steps:

    1. Get item number from page 3.

    2. Navigate to page 8.

    3. Find the object closest to the checkbox you want to click using the itemnumber found on page 3.

    4. Find all checkbox objects on page 8.

    5. Determine which checkbox is closest to the object found in step 3, using y coordinate properties.

    6. Check the closest checkbox

     

     

     

     

     

     

     

    Hi,

     

    Thanks for sending the script. I have executed the script and attached the results. The Script is telling what new Item number it found , but it is not selecting the check box at the new Item number. the Script is getting Pass. below is the message in the console:

     

    item number aquired: 0000002119. Lets go to page 8 and click some checkboxes!

    we are on page 8 now. last checkbox should be on screen

    no objects found! check search props

     

    As it is not finding any objects, and i think in the object properties that we are looking has the .text and data as 00000002117, which changes every time.

     

    Please correct me if that way i think is incorrect. thank you

     

     

  • Y5QY_gerben_delange
    Y5QY_gerben_delange
    34 Posts

    Re: Get the last row count and select the check box in last row in HTML table

    ‏2013-09-16T17:20:32Z  
    • RFTworker
    • ‏2013-09-16T16:48:15Z

    Hi,

     

    Thanks for sending the script. I have executed the script and attached the results. The Script is telling what new Item number it found , but it is not selecting the check box at the new Item number. the Script is getting Pass. below is the message in the console:

     

    item number aquired: 0000002119. Lets go to page 8 and click some checkboxes!

    we are on page 8 now. last checkbox should be on screen

    no objects found! check search props

     

    As it is not finding any objects, and i think in the object properties that we are looking has the .text and data as 00000002117, which changes every time.

     

    Please correct me if that way i think is incorrect. thank you

     

     

    hmmkay please run the attached script and post result again..

    As it is not finding any objects, and i think in the object properties that we are looking has the .text and data as 00000002117, which changes every time

    True that's why the search properties used change dynamiccaly too:

    TestObject[] itemNumberObjects = getRootTestObject().find(
    atDescendant(".class", "Html.TextNode", ".text", itemNumber),
    false);

    itemnumber is the var where the number found on page 3 is stored :)

    almost there!

     

     

  • RFTworker
    RFTworker
    66 Posts

    Re: Get the last row count and select the check box in last row in HTML table

    ‏2013-09-16T19:17:56Z  

    hmmkay please run the attached script and post result again..

    As it is not finding any objects, and i think in the object properties that we are looking has the .text and data as 00000002117, which changes every time

    True that's why the search properties used change dynamiccaly too:

    TestObject[] itemNumberObjects = getRootTestObject().find(
    atDescendant(".class", "Html.TextNode", ".text", itemNumber),
    false);

    itemnumber is the var where the number found on page 3 is stored :)

    almost there!

     

     

    Again not able to find click at the check box. got the below in Console:

     

    item number aquired: 0000002120. Lets go to page 8 and click some checkboxes!

    we are on page 8 now. last checkbox should be on screen

    no objects found! check search props

    please let me know if you want me to upload the script.

  • Y5QY_gerben_delange
    Y5QY_gerben_delange
    34 Posts

    Re: Get the last row count and select the check box in last row in HTML table

    ‏2013-09-16T19:39:34Z  
    • RFTworker
    • ‏2013-09-16T19:17:56Z

    Again not able to find click at the check box. got the below in Console:

     

    item number aquired: 0000002120. Lets go to page 8 and click some checkboxes!

    we are on page 8 now. last checkbox should be on screen

    no objects found! check search props

    please let me know if you want me to upload the script.

    I think something has gone wrong when importing/exporting my last script because i'm missing some output; I've added a method that wait's for your browser to load (public boolean waitForAllBrowsers(int timeOut) at line 400). This function will output 

    a. System.out.println("no browsers found");
     

    or

    b. .println("Al browsers have NOT been loaded within timeout!");

     or

    c. System.out

    .println("Al browsers have been loaded within timeout; seconds passed: "
    + secondsPassed);

    Since none of these lines seem to be outputed to your console, and the process flow doesn´t allow for the line ´no objects found! check search props´ to be displayed when the waitForAllBrowsers returns false (and thus outputs either a or b), i suspect something has gone wrong when importing/exporting my script. I've attached it again, this time with another name. Please import this scipt again, and make sure it containes the mentioned method. Run and post output, good things are about to happen.

     

     

    Attachments

  • RFTworker
    RFTworker
    66 Posts

    Re: Get the last row count and select the check box in last row in HTML table

    ‏2013-09-16T20:40:48Z  

    I think something has gone wrong when importing/exporting my last script because i'm missing some output; I've added a method that wait's for your browser to load (public boolean waitForAllBrowsers(int timeOut) at line 400). This function will output 

    a. System.out.println("no browsers found");
     

    or

    b. .println("Al browsers have NOT been loaded within timeout!");

     or

    c. System.out

    .println("Al browsers have been loaded within timeout; seconds passed: "
    + secondsPassed);

    Since none of these lines seem to be outputed to your console, and the process flow doesn´t allow for the line ´no objects found! check search props´ to be displayed when the waitForAllBrowsers returns false (and thus outputs either a or b), i suspect something has gone wrong when importing/exporting my script. I've attached it again, this time with another name. Please import this scipt again, and make sure it containes the mentioned method. Run and post output, good things are about to happen.

     

     

    I missed the above new steps before, but now i have imported them to diff location and see them.

    I like the way that you make the difficulty easy by saying "good things are abt to happen".

    I have executed the new script, it is not selecting the check box , but did a big find and attached is the console and Log.

     

    Thanks for your valuable suggestions.

     

     

     

     

    Attachments

  • Y5QY_gerben_delange
    Y5QY_gerben_delange
    34 Posts

    Re: Get the last row count and select the check box in last row in HTML table

    ‏2013-09-16T20:52:08Z  
    • RFTworker
    • ‏2013-09-16T20:40:48Z

    I missed the above new steps before, but now i have imported them to diff location and see them.

    I like the way that you make the difficulty easy by saying "good things are abt to happen".

    I have executed the new script, it is not selecting the check box , but did a big find and attached is the console and Log.

     

    Thanks for your valuable suggestions.

     

     

     

     

    ah some whitespace seems to be the problem.. changed:

     

    if (testObject.getProperty(".text").equals(itemNumber)

    to:

    if (testObject.getProperty(".text").toString().contains(itemNumber))

    see attached script. this will do the job i'm quite sure of it :)

    Attachments

  • RFTworker
    RFTworker
    66 Posts

    Re: Get the last row count and select the check box in last row in HTML table

    ‏2013-09-16T21:34:11Z  

    ah some whitespace seems to be the problem.. changed:

     

    if (testObject.getProperty(".text").equals(itemNumber)

    to:

    if (testObject.getProperty(".text").toString().contains(itemNumber))

    see attached script. this will do the job i'm quite sure of it :)

    Yesssss!!, it worked!! Thanks a lot for your help.

    the only issue is ..it is taking very long time to find....

     

    thanks again for your help , i know i just have copied the code as you gave, is there a way that you can explain me what we have done in more detailed manner?

    sorry for asking for more....but i have similar scenarios which i have to resue the same kind of code...so i just want to start with some basics at least ..with your help.

     

    Thank you!

     

  • Y5QY_gerben_delange
    Y5QY_gerben_delange
    34 Posts

    Re: Get the last row count and select the check box in last row in HTML table

    ‏2013-09-16T21:47:33Z  
    • RFTworker
    • ‏2013-09-16T21:34:11Z

    Yesssss!!, it worked!! Thanks a lot for your help.

    the only issue is ..it is taking very long time to find....

     

    thanks again for your help , i know i just have copied the code as you gave, is there a way that you can explain me what we have done in more detailed manner?

    sorry for asking for more....but i have similar scenarios which i have to resue the same kind of code...so i just want to start with some basics at least ..with your help.

     

    Thank you!

     

    No problem. Yes i know, this is because page 8 seems to contain 1970 texnode objects.. a shitload. Yes there is and i will; post your email adres and i will help you out. I'm glad to help. I love RFT and would love to see the community grow on this forum. I love to help out fellow testers, i have been in situations where help from the communtiy made the difference between life and death (not really, you know what i mean), so im happy to even the score. 

     

    The sollution i posted is far from optimized, it's hard to write code for an AUT without having acces to the app. The HTML source you posted gave me some insight into the AUT; made me realize some far more effecient solutions are out there.

     

    glad to help.

    bonus: http://www.youtube.com/watch?v=mTHjFeXmnHs

  • RFTworker
    RFTworker
    66 Posts

    Re: Get the last row count and select the check box in last row in HTML table

    ‏2013-09-17T17:41:11Z  

    No problem. Yes i know, this is because page 8 seems to contain 1970 texnode objects.. a shitload. Yes there is and i will; post your email adres and i will help you out. I'm glad to help. I love RFT and would love to see the community grow on this forum. I love to help out fellow testers, i have been in situations where help from the communtiy made the difference between life and death (not really, you know what i mean), so im happy to even the score. 

     

    The sollution i posted is far from optimized, it's hard to write code for an AUT without having acces to the app. The HTML source you posted gave me some insight into the AUT; made me realize some far more effecient solutions are out there.

     

    glad to help.

    bonus: http://www.youtube.com/watch?v=mTHjFeXmnHs

    Thank you, My personal Email ID is Soujukom@yahoo.com.