我写了测试任务并且有一个错误
Scenario: Set "Whiskey" value from dropdown menu # features\task2.feature:10
Given I am on the page with "ComboBox" example # features/step_definitions/task2.rb:13
When I choose "Whiskey" from drop down menu # features/step_definitions/task2.rb:16
Cannot click on element (Selenium::WebDriver::Error::ElementNotVisibleError)
./features/step_definitions/task2.rb:19:in `/^I choose "(.*?)" from drop down menu$/'
features\task2.feature:12:in `When I choose "Whiskey" from drop down menu'
And I click "Submit" button # features/step_definitions/task2.rb:22
Then I should see "You changed your selection to: 'Whiskey' " text displeyed on the page # features/step_definitions/task2.rb:26
这是黄瓜的代码
When /^I choose "(.*?)" from drop down menu$/ do |drop_down_text|
@browser.button(id: "ctl00_SampleContent_ComboBox1_ComboBox1_Button").click
@browser.ul(id: "ctl00_SampleContent_ComboBox1_ComboBox1_OptionList").li(text: drop_down_text).click
end
步骤之前
@browser.goto http://www.asp.net/ajax/ajaxcontroltoolkit/Samples/Default.aspx"
@browser.link(:text, ComboBox).click
@browser.button(id: "ctl00_SampleContent_ComboBox1_ComboBox1_Button").click
浏览器 IE9。使用 FF 就可以了。如果我选择可见元素(例如 Alfa),它会起作用。这真的很奇怪。是否需要向下滚动才能获取我的元素?