我有弹出警告与下拉值出现在弹出窗口。这些值将基于以前的选择列表。有谁能帮我用python selenium模块从这个下拉列表中选择值吗。你知道吗
<div class="none">
<div id="selectfavcolor">
<h3 class="popupTitle">Select your favourite color</h3>
<div class="clearFix pdLR15">
<!--newSelectBox start-->
<div class="newSelectBox">
<div class="dd-select-main clearFix">
<div id="myDropdown"></div>
<label id='SlctColorError' class='dispNone SlctErrors error'></label>
</div>
<div class="pdTB15 alRgt">
<a href="javascript:;" id="savecolor" class="darkYellowBtn">Save</a>
</div>
</div>
<!--newSelectBox end-->
</div>
</div>
</div>
我试过这样。但它不起作用。你知道吗
select_make = driver.find_element_by_id('myDropdown')
for option in select_make.find_elements_by_tag_name('SlctColorError'):
if option.text == 'Blue':
option.click() # select() in earlier versions of webdriver
break
假设在执行任何其他操作时,选项
Blue
出现在屏幕上,更好的方法是等到它出现在屏幕上并且可以单击,然后单击它。
一个例子(代码是用Java编写的,因为我不知道Phyton,但我相信您会设法将其转换为Phyton):
相关问题 更多 >
编程相关推荐