我试图使用Selenium从下拉元素中选择一个项目,但是唯一唯一的ID是在数据绑定值中。我试过用
<select data-bind="value: customerProvince, options: availableProvinces, optionsText: 'Name', optionsCaption: ''" class="form-control uc-not-searchable" size="1">
^{pr2}$
然后我想选择一个选项值。我尝试了以下两种代码都没有用:
customerProvinceField = browser.find_element_by_css_selector("value: customerProvince, options: availableProvinces, optionsText: 'Name', optionsCaption: ''")
customerProvinceField = browser.find_element_by_css_selector("value: customerProvince")
两者都收到错误:“消息:无效选择器:指定了无效或非法的选择器”。在
使用如下:
代码应该是
^{pr2}$参考:-
Selecting a value from a drop-down option using selenium python
希望对你有帮助
相关问题 更多 >
编程相关推荐