0

テストタスクを作成しましたが、エラーが発生しました

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

これがCucumberのコードです

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を使用すると、問題なく動作します。目に見える要素(アルファなど)を選択すると、機能します。それは本当に奇妙です。要素を取得するために下にスクロールする必要がありますか?

4

1 に答える 1

1

ドロップダウンの高さを増やすことができます。これにより、IEは最初は隠されていたオプションにアクセスできるようになります。例えば:

b.button(id: "ctl00_SampleContent_ComboBox1_ComboBox1_Button").click
b.execute_script("document.getElementById('ctl00_SampleContent_ComboBox1_ComboBox1_OptionList').style.height='1000px';")
于 2013-01-30T18:53:02.783 に答える