我想测试Python
Selenium
中的页面,它使用AngularJS
。它包含一个select选项,我尝试了很多选项来选择它,但是失败了。在
<select id="xtzpp001" ng-model="..." ng-options="...." ng-change="changeView()">
<option value class>select</option>
<option value="200" selected="selected">Student 1</option>
<option value="201">Student 2</option>
<option value="202">Student 3</option>
</select>
就像我说的,我试着
^{pr2}$那么
from selenium.webdriver.support.ui import Select
select = Select(driver.find_element_by_id('xtzpp001'))
for i in select.options:
.......etc etc
我也使用显式等待。在
我开始知道pytractor可以在这种情况下帮助我(虽然还没有被积极开发),但是我找不到任何关于使用pytractor选择选项的文档。在
有没有其他方法可以达到这个目的??或pytractor同等产品?在
或者我可以使用量角器(或任何javascript框架)从这个阶段继续在Javascript
中进行测试,并在Python
中集成/回调结果吗??在
如果您尝试了所有可能的尝试,但始终没有成功,您应该尝试使用
execute_script()
,如下所示:-使用Select class fromselenium.webdriver.support.ui。将select webelement传递给构造函数。使用selectByVisibleText。参考@alecxe在post-Selenium - Python - drop-down menu option value中的答案
也可以使用操作单击菜单项,下面是一个示例:
相关问题 更多 >
编程相关推荐