I'm having the following problem. I have a dropdown that is hidden so when I make the Select and run the test i get the following error:
selenium.common.exceptions.ElementNotVisibleException: Message: element not visible: Element is not currently visible and may not be manipulated
below is the code i have been trying:
cur=Select(driver.find_element_by_id("currencyCode"))
cur.select_by_visible_text('USD')
below is the html syntax of the code:
<div class="form-group true-grid-3">
<label for="currencyCode">Currency</label>
<select id="currencyCode" name="criteria.currencyCode" class="form-control" style="display: none;">
<option value="CHF">CHF</option>
<option value="EUR">EUR</option>
<option value="GBP">GBP</option>
<option value="JPY">JPY</option>
<option value="USD">USD</option>
设置display: none
至display: block
中的CSS属性使得元件变得可见。
driver.execute_script("document.getElementById('criteria.currencyCode').style.display = 'block';")
您可以尝试调用下拉驱动程序driver.find_element_by_id("currencyCode").click()
,然后在显示选项时选择所需的选项driver.find_element_by_xpath('//option[@value="USD"]').click()
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.