Quality is delighting customers
Tags:
Please elaborate kind of error you are getting.
Let's start with a small table with a Select list inside of it.
<table id="testRuns" border="0" valign="top" align="left" cellpadding=0 cellspacing=0 class="TABLE_section_bar2">
<tr valign="top">
<td valign="top" class="TD_tool_bar1"><b>Show testcases by testrun: </b></td>
<td valign="top" class="TD_tool_bar1">
<select id="some_dynamic_value" multiple size=2 class="select_small">
<option value="0" selected>---<br>
<option value="1505_2557">R10.4_Preprod<br>
<option value="1505_2785">R10.5_Preprod<br>
<option value="1505_3272">R10.6_Preprod<br>
<option value="1505_3340">R11.1_PreProd<br>
<option value="1505_3506">R11.2_Preprod
</select>
</td>
</table>
What you want to do to gain access to the select list is move backwards in the DOM until you have a clear and consistent path to the select list. In the case above, as long as my TABLE always has an ID of "testRuns" and my select list is always inside a TD tag, and there is only one TD with a select list in that table, we could do this...
String[] options = selenium.getSelectOptions("//table[@id='testRuns']//tr//td[@class='TD_tool_bar1']//select");
There is a possibility that your select list has a class or some additional attribute that will help in locating it. In the example above I could add the class to the select to make it more specific...//select[@class='select_small']
If you want the ID of the select list, you can ask for it like this...
String selectID = selenium.getAttribute("//table[@id='testRuns']//tr//td[@class='TD_tool_bar1']//select[@class='select_small']@id");
Then, getting the values is as easy as ...
String[] options = selenium.getSelectOptions("//select[@id='" + selectID + "']");
or
String[] options = selenium.getSelectOptions("//select[@id='" + selenium.getAttribute("//table[@id='testRuns']//tr//td[@class='TD_tool_bar1']//select[]@id") + "']");
© 2022 Created by Quality Testing.
Powered by