How do I access all the elements on a page?

1 view
Skip to first unread message

Judy

unread,
Jun 12, 2008, 11:08:36 AM6/12/08
to selenium-users...@googlegroups.com
I have several pages with dynamically generated forms divided into sections:

> <form>
> <div id="div_section_name">
> <table class="formtable">
> <tr><td>label</td><td>input field, dropdown or checkbox</td><td>range info about the field</td></tr>
> </table>
> <div id="div_section2_name">
> <table class="formtable">
> <tr><td>label</td><td>input field, dropdown or checkbox</td><td>range info about the field</td></tr>
> </table>
> </div>
The sections and elements in the sections are configurable. My goal is to pull out all of the form elements and test the error/changed processing on each, using the ranges in the <td> next to them for the text fields.

What's hanging me up is that getting the count of //tables[@class='formtable'] doesn't tell me how to get to each of those tables. What am I missing? Since the tables are each in divs they are actually all table[1]; there are other divs on the page outside of the form so they aren't eay to access by number.

Any hints would be greatly appreciated!!

Judy

Judy

unread,
Jun 13, 2008, 10:01:27 AM6/13/08
to selenium-users...@googlegroups.com
Yes, the div ID's are dynamically generated. But I realized that the Divs I cared about are all direct children of the only form. So I could iterate through the divs if I specifed they were direct children of the form after getting the count of the tables I cared about:

> tableCount = get_xpath_count( "//table[\@class='formtable']" )
>
> foreach my $tbl ( 1..$tableCount ){
> assign_id( "//form[1]//div\[ $tbl \]//table\[1\]", "unique_tmp_id" )
>
> use unique_tmp_id to access all the parts of each table easily.
> }

Reply all
Reply to author
Forward
0 new messages