【发布时间】:2013-06-26 15:56:36
【问题描述】:
我知道这个问题听起来像是重复,但我已经尝试了在这里找到的解决方案,但到目前为止没有一个对我有用。
从以下问题实施解决方案:
https://stackoverflow.com/questions/7489917/using-selenium-2-and-firefox-how-do-you-select-a-dropdown-selection Selenium WebDriver and DropDown Boxes
Ruby 中的方法参考: http://selenium.googlecode.com/svn/trunk/docs/api/rb/index.html#selenium-webdriver
我正在使用 selenium 和黄瓜来测试一个网站。我在 IE 8 中工作。
chan_text = @driver.find_element(:css,'select#check-list option').text
select_list = @driver.find_element(:css,'select#check-list')
dropdown = Selenium::WebDriver::Support::Select.new(select_list)
dropdown.select_by(:text, chan_text)
源代码如下所示:
<select id="check_list" multiple="">
<option selected="" value="81" label="MILK">MILK</option>
<option value="82" label="CHEESE">CHEESE</option>
<option value="83" label="DOUGHNUTS">DOUGHNUTS</option>
</select>
选择选项时,页面应刷新。这根本没有发生,菜单只是保持打开状态。任何帮助表示赞赏,如果需要,请索取更多信息。如果它真的是重复的,我将删除这个问题。
【问题讨论】:
-
需要网页url,才能看到页面源html。
-
对不起,我无法分享网页。如果没有它就无法回答,我将删除问题并找到另一种提问方式。
标签: ruby selenium drop-down-menu html-select