ruby - Watir-webdriver throws 'not clickable' error even when element is visible, present -
i trying automate tests in ruby using latest watir-webdriver 0.9.1, selenium-webdriver 2.53.0 , chrome extension 2.21. website testing has static headers @ top or static footers @ bottom. hence since watir auto-scrolls element view before clicking, elements hidden under static header or static footer. not want set desired_capabitlites (elementscrollbehavior) 1 or 0 websites testing can have both - static header or static footer or both.
hence question 1) why watir throw exception 'element not clickable' when element visible , present? see ruby code ( have picked random company website example) , results below.
2) how can resolve without resorting elementscrollbehaviour?
ruby code:
require 'watir-webdriver' browser = watir::browser.new :chrome begin # step 1 browser.goto "shop.coles.com.au/online/mobile/national" # step 2 - click on 'full website' link @ bottom link = browser.link(text: "full website") #check if link exists, present , visible? puts link.exists? puts link.present? puts link.visible? #click on link link.click rescue => e puts e.inspect ensure sleep 5 end puts browser.url browser.close
result:
$ ruby link_not_clickable.rb
true true true
selenium::webdriver::error::unknownerror: unknown error: element not clickable @ point (460, 1295). other element receive click: div class="shoppingfooter"...div
(session info: chrome=50.0.2661.75) (driver info: chromedriver=2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4),platform=mac os x 10.10.5 x86_64)> http://shop.coles.com.au/online/mobile/national
thanks!
you can click @ element without getting visible. check out:
link.fire_event('click')
but very not decision far click element if not visible or in case when impossible click (because of broken sticky footer example).
that's why better wait fooler, scroll page , click like:
browser.div(id: "footermessagearea").wait_until_present browser.execute_script("window.scrollto(0, document.body.scrollheight);") link.click
Comments
Post a Comment