There is the following code:
<select id="region" tabindex="-1" style="display: none;">
<option value=""></option>
<option value="1">Республика Адыгея</option>
<option value="2">Республика Башкортостан</option>
<option value="3">Республика Бурятия</option>
</select>
I need to make field value number 2. But when I write my code:
element = Select(driver.find_element(By.XPATH, '//*[@id="region"]'))
element.select_by_value('2')
Python returns an error:
Message: element not interactable: Element is not currently visible and may not be manipulated
How to fix this and set the required data?
CodePudding user response:
Your region
element has the property display set to none
, which makes it invisible on the screen. However, the functions you are trying to execute may require the object to be completely visible, without any property that can hide it. So the best solution for this case is to remove the following property from style
:
display: none;
CodePudding user response:
You can use by below ways
element = Select(driver.find_element(By.XPATH, '//select[@id="region"]'))
element.select_by_index(3)
Or
element = Select(driver.find_element(By.XPATH, '//select[@id="region"]'))
element.select_by_value('2')