繁体   English   中英

我在Python Selenium中使用了Select,但是无法选择值

[英]I used Select in Python Selenium but not able to select values

我在Python中使用单元测试,在Python Selenium中使用了Select,但无法选择值,因此建议我从下拉框中选择值

请检查以下是我的代码:

self.login_element= Select(self.driver.find_element_by_xpath('//*[@name="field_DOBDay"]'))

        self.login_element.select_by_visible_text('01')
        self.login_element.select_by_index('1')
        self.login_element.select_by_value('1')

我没有有关您的html来源的信息,但是,

请尝试使用带有特定optionText的以下代码,option_text应该与选项文本完全匹配:

find_element_by_xpath("//*[@name="field_DOBDay"]/option[text()='option_text']").click()

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM