[英]I used Select in Python Selenium but not able to select values
I am using Unit test in Python and I used Select in Python Selenium but not able to select values, so please suggest me to select values from Drop down box 我在Python中使用单元测试,在Python Selenium中使用了Select,但无法选择值,因此建议我从下拉框中选择值
Please check below is my code: 请检查以下是我的代码:
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')
I don't have information about your html source but, 我没有有关您的html来源的信息,但是,
Please try following code with specific optionText, option_text should exactly match with options text: 请尝试使用带有特定optionText的以下代码,option_text应该与选项文本完全匹配:
find_element_by_xpath("//*[@name="field_DOBDay"]/option[text()='option_text']").click()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.