[英]Unable to select dropdown value using selenium python
I need to select a dropdown value , I checked the code it doesnt contain select class.我需要选择一个下拉值,我检查了它不包含选择类的代码。 Is there any way we can select the value without select class
有什么办法可以在没有选择类的情况下选择值
By this I am clicking on dropdown which then enables the dropdown values driver.find_element_by_xpath("(//div[@class='ot-lookup__input-container'])").click()
That is the dropdown通过这个,我点击下拉菜单,然后启用下拉值
driver.find_element_by_xpath("(//div[@class='ot-lookup__input-container'])").click()
那是下拉菜单
The code for Xpath is : (**it is same for every value) Xpath 的代码是:(**每个值都相同)
<button _ngcontent-fru-c1=""
class="slds-media slds-listbox__option slds-listbox__option_entity slds-listbox__option_has-meta tabbable-button"
role="option"
type="button"
id="listbox-option-unique-id-[object Object]">
<!----><!---->Skipped<!---->
</button>
You can.你可以。 Click to open dropdown and then click on required option (in your case button).
单击以打开下拉菜单,然后单击所需选项(在您的情况下按钮)。 In code below I used
WebDriverWait
to wait until the button with text Skipped will be clickable:在下面的代码中,我使用
WebDriverWait
等待带有文本跳过的按钮可点击:
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
# ...
wait = WebDriverWait(driver, 10)
# ...
driver.find_element_by_xpath("(//div[@class='ot-lookup__input-container'])").click()
wait.until(EC.element_to_be_clickable((By.XPATH, "//button[normalize-space()='Skipped']"))).click()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.