'Incrementing the value attribute of Select option using Python Selenium
I want to increment the value of "i" so that it can loop it to the next value in the drop down after a task is executed. I tried with for loop as well. In both the cases the output states as "argument of type 'int' is not iterable". Any reference of executing it will be appreciated.
select = Select(driver.find_element(By.ID, "court_code"))
i = 1
while (i<=7):
select.select_by_value(i)
i += 1
This is the html code for reference:
<option value="0">Option 1</option>
<option value="1">Option 2</option>
.
<option value="7">Option 6</option>
<option value="8">Option 7</option>
Solution 1:[1]
As per the while() loop:
while (i<=7):
i is of type integer, where as the argument value in select_by_value(value) accepts a string.
Solution
You need to convert the type of the variable i from integer to string while passing as an argument to select_by_value() as follows:
while (i<=7):
select.select_by_value(str(i))
i += 1
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | undetected Selenium |
