Selenium Webdriver (Ruby) : Cannot click on button - element not found -
this page code:
<div class="modal-buttons"> <button class="button-orange" ng-click="cancel()"> <span> cancel </span> <span class="icon cancel"></span> </button> <button class="button-orange" ng-click="apply()"> <span> apply </span> <span class="icon run"></span> </button>
as can see - modal has 2 buttons , have tried dozen different ways - want click on button labeled "apply" no matter route take - keeps saying element not visible.
here of things i've tried:
# @driver.find_element(:class, "button-orange")[2].click # @driver.find_element(:xpath, "//div[4]/div/div[2]/div[3]/button[2]").click # @driver. find_element(:link_text, 'apply').click # @driver. find_element(:tag, 'apply').click # @driver.find_element(:css, "input[value='apply']").click(); # @driver.find_element(:css, "input[value='apply']").click(); # @driver.find_element(:xpath, "//button[contains(text(),'apply')]").click # @driver.find_element(:xpath, "//button[contains(text(),'apply')]").click # @driver.find_element(:xpath, "//input[@value='apply']").click(); # @driver.find_element(:class, "button-orange.icon-run").click # @driver.find_element(:css,'a[class$="button-orange"]').click # @driver.find_element(:xpath, "").clear
the exact error is:
error: test_login_to_chute(logintochute) selenium::webdriver::error::elementnotvisibleerror: element not visible (session info: chrome=36.0.1985.125) (driver info: chromedriver=2.10.267521,platform=windows nt 6.3 x86_64) c:/ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.42.0/lib/selenium/webdr iver/remote/response.rb:51:in `assert_ok' c:/ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.42.0/lib/selenium/webdr iver/remote/response.rb:15:in `initialize' c:/ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.42.0/lib/selenium/webdr iver/remote/http/common.rb:59:in `new' c:/ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.42.0/lib/selenium/webdr iver/remote/http/common.rb:59:in `create_response' c:/ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.42.0/lib/selenium/webdr iver/remote/http/default.rb:66:in `request' c:/ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.42.0/lib/selenium/webdr iver/remote/http/common.rb:40:in `call' c:/ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.42.0/lib/selenium/webdr iver/remote/bridge.rb:634:in `raw_execute' c:/ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.42.0/lib/selenium/webdr iver/remote/bridge.rb:612:in `execute' c:/ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.42.0/lib/selenium/webdr iver/remote/bridge.rb:369:in `clickelement' c:/ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.42.0/lib/selenium/webdr iver/common/element.rb:54:in `click' c:/analytics/automatedtesting/devenv/wonderland/full regression/2.login_to_chute .rb:165:in `test_login_to_chute' 162: @driver.find_element(:xpath, "(//input[@type='text'])[8]").clear 163: @driver.find_element(:xpath, "(//input[@type='text'])[8]").send_ keys "25" 164: => 165: @driver.find_element(:xpath, "//div[4]/div/div[2]/div[3]/button[2]").c lick
thank helping.
here's ended being deal.
because website 1 angular page, it's loading bunch of things in background. including multiple other buttons aren't visible.
so here's ended using:
@driver.find_elements(:xpath, "//button")[-1].click
and updated find_element variable find visible elements.
def find_visible_element(how, what) elems = @driver.find_elements(how, what).select { |e| e.displayed? } len = elems.length if len == 0 raise "no matches found." elsif len > 1 raise "ambiguous match. found #{len} matches." end elems.first end
Comments
Post a Comment