0

ruby で Selenium を介してドロップダウンと送信ボックスを処理するのに本当に苦労しています。私はこれに行き着き、他の多くのオプションを試しました:

mySelect = browser.find_element(:id, "bulk_action")
option = mySelect.find_element(:css, "option[value='Accepted']")

応答:

[remote server] file:///var/folders/tt/pbz121011d1fvj5xmbyg78y00000gn/T/webdriver-profile20151012-46016-5sf82y/extensions/fxdriver@googlecode.com/components/driver-component.js:10659:in `FirefoxDriver.prototype.findElementInternal_': Unable to locate element: {"method":"id","selector":"bulk_action"} (Selenium::WebDriver::Error::NoSuchElementError)
from [remote server] file:///var/folders/tt/pbz121011d1fvj5xmbyg78y00000gn/T/webdriver-profile20151012-46016-5sf82y/extensions/fxdriver@googlecode.com/components/driver-component.js:10668:in `FirefoxDriver.prototype.findElement'
from [remote server] file:///var/folders/tt/pbz121011d1fvj5xmbyg78y00000gn/T/webdriver-profile20151012-46016-5sf82y/extensions/fxdriver@googlecode.com/components/command-processor.js:12534:in `DelayedCommand.prototype.executeInternal_/h'
from [remote server] file:///var/folders/tt/pbz121011d1fvj5xmbyg78y00000gn/T/webdriver-profile20151012-46016-5sf82y/extensions/fxdriver@googlecode.com/components/command-processor.js:12539:in `DelayedCommand.prototype.executeInternal_'
from [remote server] file:///var/folders/tt/pbz121011d1fvj5xmbyg78y00000gn/T/webdriver-profile20151012-46016-5sf82y/extensions/fxdriver@googlecode.com/components/command-processor.js:12481:in `DelayedCommand.prototype.execute/<'
from /Users/chris/.rvm/gems/ruby-2.2.3/gems/selenium-webdriver-2.48.0/lib/selenium/webdriver/remote/response.rb:70:in `assert_ok'
from /Users/chris/.rvm/gems/ruby-2.2.3/gems/selenium-webdriver-2.48.0/lib/selenium/webdriver/remote/response.rb:34:in `initialize'
from /Users/chris/.rvm/gems/ruby-2.2.3/gems/selenium-webdriver-2.48.0/lib/selenium/webdriver/remote/http/common.rb:78:in `new'
from /Users/chris/.rvm/gems/ruby-2.2.3/gems/selenium-webdriver-2.48.0/lib/selenium/webdriver/remote/http/common.rb:78:in `create_response'
from /Users/chris/.rvm/gems/ruby-2.2.3/gems/selenium-webdriver-2.48.0/lib/selenium/webdriver/remote/http/default.rb:90:in `request'
from /Users/chris/.rvm/gems/ruby-2.2.3/gems/selenium-webdriver-2.48.0/lib/selenium/webdriver/remote/http/common.rb:59:in `call'
from /Users/chris/.rvm/gems/ruby-2.2.3/gems/selenium-webdriver-2.48.0/lib/selenium/webdriver/remote/bridge.rb:664:in `raw_execute'
from /Users/chris/.rvm/gems/ruby-2.2.3/gems/selenium-webdriver-2.48.0/lib/selenium/webdriver/remote/bridge.rb:642:in `execute'
from /Users/chris/.rvm/gems/ruby-2.2.3/gems/selenium-webdriver-2.48.0/lib/selenium/webdriver/remote/bridge.rb:611:in `find_element_by'
from /Users/chris/.rvm/gems/ruby-2.2.3/gems/selenium-webdriver-2.48.0/lib/selenium/webdriver/common/search_context.rb:61:in `find_element'
from mass_assign.rb:23:in `<main>'

ページのソース コード

オプションを選択して送信ボタンから送信する方法について何か考えはありますか?

4

1 に答える 1

0
mass_accept = browser.find_element(id: 'bulk_action')
select_list = Selenium::WebDriver::Support::Select.new(mass_accept)
select_list.select_by(:text, 'Accept')
dropdown_button = browser.find_element(:class, "button--primary")
dropdown_button.click

http://elementalselenium.com/tips/5-select-from-a-dropdownに多大な感謝を込めて

于 2015-10-12T16:55:31.097 に答える