单击dropDownMenu项目-硒红宝石

use*_*303 2 ruby selenium option drop-down-menu

我试图单击一个按钮“复制地址”,然后单击下拉菜单项“发货至开票”选项。我可以按ID单击按钮,但是我的下一行脚本会引发错误,这就是我所拥有的-

click_element(@driver, :id, 'copyAddress')
@driver.find_element(:class, 'dropDownMenu')

#select(@driver, :class, 'dropDownMenu', 'Billing to Shipping')
#@driver.find_element(:class, 'dropDownItemOver')
#select(@driver, :class, 'dropDownItem', 'Billing to Shipping')
Run Code Online (Sandbox Code Playgroud)

到目前为止,我已经尝试了所有这些方法,但是没有运气。

任何帮助...。谢谢

gru*_*rus 8

我相信您和这个家伙问的是同样的问题...因为selenium-webdriver用相同的方式对待很多元素。

如何在ruby中设置使用Selenium WebDriver(Selenium 2.0)客户端选择的选项

dropDownMenu = @driver.find_element(:class, 'dropDownMenu')
option = Selenium::WebDriver::Support::Select.new(dropDownMenu)
option.select_by(:text, 'Billing to Shipping')
option.select_by(:value, 'Billing to Shipping')
Run Code Online (Sandbox Code Playgroud)