could someone help with such task: I need to pick drop_down_1, select first option, then automatically in the another drop_down_2 the list with options will be shown, I have to select first option in drop_down_2, click button Get Results, after some time when the results will be shown to delete it and select the second option and so on and so forth. So, I need to iterate through each option of the drop_down_2 for each option of the drop_down_1.
Some html code below:
First drop down list with many options:
<select id="manufacturer-selector" data-bind="value: selectedManufacturer">
<option value=""></option>
<option value="5637148326">Nokia</option>
<option value="5637148327">Sony</option>
<option value="5637148328">Lenovo-new</option>
....
Second drop down list with many options:
<select id="product-selector" data-bind="attr: { disabled: countManufacturerProducts() === 0 }, foreach: manufacturerProducts, value: selectedProduct">
<option data-bind="text: Name, attr: { value: ID }" value="5637191581">390</option>
<option data-bind="text: Name, attr: { value: ID }" value="5637201719">390 Screenphone</option>
<option data-bind="text: Name, attr: { value: ID }" value="5637206334">470 Screenphone</option>47
Do I need to create a loop and inside it one more loop?
first of all -- use selenium.support.ui
create 2 select elements
SelectElement select1 = driver.FindElement(By....);
SelectElement select2 = driver.FindElement(By....);
and after to count how much "option" elements in select 1.
var optionCounter1 = driver.FindElements(By...).Count;
var optionCounter2 = driver.FindElements(By...).Count;
for (int currOption1 =1; currOption1 < optionCounter; currOption1 ++)
{
select1.SelectByIndex(currOption1 );
for (int currOption2 =1; currOption2 < optionCounter; currOption2 ++)
{
select1.SelectByIndex(currOption1);
select2.SelectByIndex(currOption2);
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.