Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clicking a link which has an image with display attribute set to block does not navigate to URL #1097

Closed
placetne opened this issue Dec 10, 2017 · 3 comments

Comments

@placetne
Copy link

placetne commented Dec 10, 2017

System

  • Version: 0.19.1
  • Platform: Windows 10
  • Firefox: 57.0.2
  • Selenium: Selenium-Webdriver 3.8.0

Testcase

Test.html

<!DOCTYPE html>
<html>
<head>
<style>
	img {display: block;}
</style>
<title>T</title>
</head>
<body>
	<a href="https://www.google.com/" id="bcd"><img src="https://i.imgur.com/8VN3FVV.jpg" id="efg" />Bye</a>
</body>
</html>

Test.rb

require 'selenium-webdriver'

capabilities = Selenium::WebDriver::Remote::Capabilities.firefox
capabilities['firefox_binary'] = 'C:\\Program Files\\Firefox2\\Firefox.exe'
Selenium::WebDriver.logger.level = :debug
options = Selenium::WebDriver::Firefox::Options.new(log_level: :trace)
driver = Selenium::WebDriver.for :firefox, desired_capabilities: capabilities, options: options
driver.navigate.to 'http://localtest2/Test.html'

sleep(5)
element = driver.find_element(:css, 'a')
element.click

puts 'ELEMENT CLICKED. Sleeping for 5 seconds.'
sleep(5)
driver.quit

Stacktrace

Trace-level log

1512904551608	geckodriver	INFO	geckodriver 0.19.1 (0000000000000000000000000000000000000000 2017-10-31)
1512904551615	geckodriver	INFO	Listening on 127.0.0.1:4444
2017-12-10 05:15:52 INFO Selenium Skipping handshake as we know it is W3C.
2017-12-10 05:15:52 INFO Selenium -> POST session
2017-12-10 05:15:52 INFO Selenium    >>> http://127.0.0.1:4444/session | {"desiredCapabilities":{"browserName":"firefox","version":"","platform":"ANY","javascriptEnabled":true,"cssSelectorsEnabled":true,"takesScreenshot":true,"nativeEvents":false,"rotatable":false,"firefox_binary":"C:\\Program Files\\Firefox2\\Firefox.exe","moz:firefoxOptions":{"log":{"level":"trace"}}},"capabilities":{"firstMatch":[{"browserName":"firefox","moz:firefoxOptions":{"binary":"C:\\Program Files\\Firefox2\\Firefox.exe"}}]}}
2017-12-10 05:15:52 DEBUG Selenium      > {"Accept"=>"application/json", "Content-Type"=>"application/json; charset=utf-8", "Content-Length"=>"433"}
1512904552182	mozrunner::runner	INFO	Running command: "C:\\Program Files\\Firefox2\\Firefox.exe" "-marionette" "-profile" "C:\\Users\\myusername\\AppData\\Local\\Temp\\rust_mozprofile.3Wuww5CfKemX"
1512904552928	Marionette	INFO	Enabled via --marionette
Unable to read VR Path Registry from C:\Users\myusername\AppData\Local\openvr\openvrpaths.vrpath
[Child 16440, Chrome_ChildThread] WARNING: pipe error: 109: file z:/build/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line 346
[Child 16440, Chrome_ChildThread] WARNING: pipe error: 109: file z:/build/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line 346
1512904554422	Marionette	INFO	Listening on port 7665
1512904555346	Marionette	DEBUG	Register listener.js for window 4294967297
2017-12-10 05:15:55 INFO Selenium <- {"value": {"sessionId":"5164bb96-0fae-47ea-9eab-fabba0cd80a9","capabilities":{"acceptInsecureCerts":false,"browserName":"firefox","browserVersion":"57.0.2","moz:accessibilityChecks":false,"moz:headless":false,"moz:processID":996,"moz:profile":"C:\\Users\\myusername\\AppData\\Local\\Temp\\rust_mozprofile.3Wuww5CfKemX","moz:webdriverClick":false,"pageLoadStrategy":"normal","platformName":"windows_nt","platformVersion":"10.0","rotatable":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000}}}}
2017-12-10 05:15:55 INFO Selenium Detected W3C dialect.
2017-12-10 05:15:55 INFO Selenium -> POST session/5164bb96-0fae-47ea-9eab-fabba0cd80a9/url
2017-12-10 05:15:55 INFO Selenium    >>> http://127.0.0.1:4444/session/5164bb96-0fae-47ea-9eab-fabba0cd80a9/url | {"url":"http://localtest2/Test.html"}
2017-12-10 05:15:55 DEBUG Selenium      > {"Accept"=>"application/json", "Content-Type"=>"application/json; charset=utf-8", "Content-Length"=>"37"}
1512904555372	Marionette	DEBUG	Received DOM event "beforeunload" for "about:blank"
1512904555393	Marionette	DEBUG	Received DOM event "pagehide" for "about:blank"
1512904555394	Marionette	DEBUG	Received DOM event "unload" for "about:blank"
1512904555402	Marionette	DEBUG	Received DOM event "DOMContentLoaded" for "http://localtest2/Test.html"
1512904555468	Marionette	DEBUG	Received DOM event "pageshow" for "http://localtest2/Test.html"
2017-12-10 05:15:55 INFO Selenium <- {"value": {}}
2017-12-10 05:16:00 INFO Selenium -> POST session/5164bb96-0fae-47ea-9eab-fabba0cd80a9/element
2017-12-10 05:16:00 INFO Selenium    >>> http://127.0.0.1:4444/session/5164bb96-0fae-47ea-9eab-fabba0cd80a9/element | {"using":"css selector","value":"a"}
2017-12-10 05:16:00 DEBUG Selenium      > {"Accept"=>"application/json", "Content-Type"=>"application/json; charset=utf-8", "Content-Length"=>"36"}
2017-12-10 05:16:00 INFO Selenium <- {"value":{"element-6066-11e4-a52e-4f735466cecf":"4dd44794-0742-43ee-998a-9612462404b3"}}
2017-12-10 05:16:00 INFO Selenium -> POST session/5164bb96-0fae-47ea-9eab-fabba0cd80a9/element/4dd44794-0742-43ee-998a-9612462404b3/click
1512904560708	Marionette	DEBUG	Canceled page load listener because no navigation has been detected
2017-12-10 05:16:00 INFO Selenium <- {"value": {}}
ELEMENT CLICKED. Sleeping for 5 seconds.
2017-12-10 05:16:05 INFO Selenium -> DELETE session/5164bb96-0fae-47ea-9eab-fabba0cd80a9
2017-12-10 05:16:05 INFO Selenium <- {"value": {}}

Clicking on the link does not navigate to https://www.google.com/ as expected.
There are 2 workarounds so that it does navigate to https://www.google.com.

  1. Removing the img {display: block;} from the html will fix it.
  2. Changing the test.rb line from

element = driver.find_element(:css, 'a')
to
element = driver.find_element(:css, 'a img')

also fixes it.

@placetne placetne changed the title Can't click a link has an image with display as block Can't click a link which has an image with display attribute set to block Dec 10, 2017
@placetne placetne changed the title Can't click a link which has an image with display attribute set to block Click a linking which has an image with display attribute set to block does not navigate to URL Dec 11, 2017
@placetne placetne changed the title Click a linking which has an image with display attribute set to block does not navigate to URL Clicking a linking which has an image with display attribute set to block does not navigate to URL Dec 11, 2017
@placetne placetne changed the title Clicking a linking which has an image with display attribute set to block does not navigate to URL Clicking a link which has an image with display attribute set to block does not navigate to URL Dec 11, 2017
@andreastt
Copy link
Contributor

Can you try this with Firefox Nightly or Firefox 58, where we enabled WebDriver conforming element clicks? See https://www.hskupin.info/2017/12/15/element-interactability-checks-with-geckodriver-and-firefox-58/ for more details.

@placetne
Copy link
Author

You can close this problem because I found out it's a duplicate of issue 653

Here's my stacktrace and trace level log for informational purpose when using Firefox 58 beta 9. This time it throws an ElementNotInteractableError.

1513575042525	geckodriver	INFO	geckodriver 0.19.1 (0000000000000000000000000000000000000000 2017-10-31)
1513575042568	geckodriver	INFO	Listening on 127.0.0.1:4444
2017-12-17 23:30:42 INFO Selenium Skipping handshake as we know it is W3C.
2017-12-17 23:30:42 INFO Selenium -> POST session
2017-12-17 23:30:42 INFO Selenium    >>> http://127.0.0.1:4444/session | {"desiredCapabilities":{"browserName":"firefox","marionette":true,"timeouts":{},"moz:firefoxOptions":{"binary":"C:\\Program Files\\Firefox3\\Firefox.exe","log":{"level":"trace"}}},"capabilities":{"firstMatch":[{"browserName":"firefox","timeouts":{},"moz:firefoxOptions":{"binary":"C:\\Program Files\\Firefox3\\Firefox.exe","log":{"level":"trace"}}}]}}
2017-12-17 23:30:42 DEBUG Selenium      > {"Accept"=>"application/json", "Content-Type"=>"application/json; charset=utf-8", "Content-Length"=>"351"}
1513575043319	mozrunner::runner	INFO	Running command: "C:\\Program Files\\Firefox3\\Firefox.exe" "-marionette" "-profile" "C:\\Users\\myusername\\AppData\\Local\\Temp\\rust_mozprofile.XOvgF8WbcTuP"
1513575045382	geckodriver::marionette	TRACE	  connection attempt 0/600
1513575045884	Marionette	DEBUG	Received observer notification "profile-after-change"
1513575046250	Marionette	DEBUG	Received observer notification "command-line-startup"
1513575046250	Marionette	INFO	Enabled via --marionette
1513575047489	geckodriver::marionette	TRACE	  connection attempt 1/600
1513575049425	Marionette	DEBUG	Received observer notification "sessionstore-windows-restored"
1513575049852	geckodriver::marionette	TRACE	  connection attempt 2/600
1513575049951	Marionette	DEBUG	Received observer notification "domwindowclosed"
1513575050231	Marionette	DEBUG	Setting recommended pref toolkit.cosmeticAnimations.enabled to false
1513575050231	Marionette	DEBUG	Setting recommended pref datareporting.policy.dataSubmissionPolicyAccepted to false
1513575050233	Marionette	DEBUG	New connections are accepted
1513575050233	Marionette	INFO	Listening on port 9171
1513575051098	geckodriver::marionette	DEBUG	Connected to Marionette on localhost:9171
1513575051100	Marionette	DEBUG	Accepted connection 0 from 127.0.0.1:9199
1513575051100	geckodriver::marionette	TRACE	<- {"applicationType":"gecko","marionetteProtocol":3}
1513575051100	geckodriver::marionette	TRACE	-> 137:[0,1,"newSession",{"browserName":"firefox","capabilities":{"desiredCapabilities":{"browserName":"firefox","timeouts":{}}},"timeouts":{}}]
1513575051102	Marionette	TRACE	0 -> [0,1,"newSession",{"browserName":"firefox","capabilities":{"desiredCapabilities":{"browserName":"firefox","timeouts":{}}},"timeouts":{}}]
1513575051201	Marionette	DEBUG	Register listener.js for window 4294967297
1513575051219	Marionette	TRACE	0 <- [1,1,null,{"sessionId":"744bd9ae-4cfd-48a7-98e7-86ba7b328df0","capabilities":{"browserName":"firefox","browserVersion":"58.0" ... ssID":24248,"moz:profile":"C:\\Users\\myusername\\AppData\\Local\\Temp\\rust_mozprofile.XOvgF8WbcTuP","moz:webdriverClick":true}}]
1513575051219	geckodriver::marionette	TRACE	<- [1,1,null,{"sessionId":"744bd9ae-4cfd-48a7-98e7-86ba7b328df0","capabilities":{"browserName":"firefox","browserVersion":"58.0","platformName":"windows_nt","platformVersion":"10.0","pageLoadStrategy":"normal","acceptInsecureCerts":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000},"rotatable":false,"moz:accessibilityChecks":false,"moz:headless":false,"moz:processID":24248,"moz:profile":"C:\\Users\\myusername\\AppData\\Local\\Temp\\rust_mozprofile.XOvgF8WbcTuP","moz:webdriverClick":true}}]
1513575051219	webdriver::server	DEBUG	<- 200 OK {"value": {"sessionId":"744bd9ae-4cfd-48a7-98e7-86ba7b328df0","capabilities":{"acceptInsecureCerts":false,"browserName":"firefox","browserVersion":"58.0","moz:accessibilityChecks":false,"moz:headless":false,"moz:processID":24248,"moz:profile":"C:\\Users\\myusername\\AppData\\Local\\Temp\\rust_mozprofile.XOvgF8WbcTuP","moz:webdriverClick":true,"pageLoadStrategy":"normal","platformName":"windows_nt","platformVersion":"10.0","rotatable":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000}}}}
2017-12-17 23:30:51 INFO Selenium <- {"value": {"sessionId":"744bd9ae-4cfd-48a7-98e7-86ba7b328df0","capabilities":{"acceptInsecureCerts":false,"browserName":"firefox","browserVersion":"58.0","moz:accessibilityChecks":false,"moz:headless":false,"moz:processID":24248,"moz:profile":"C:\\Users\\myusername\\AppData\\Local\\Temp\\rust_mozprofile.XOvgF8WbcTuP","moz:webdriverClick":true,"pageLoadStrategy":"normal","platformName":"windows_nt","platformVersion":"10.0","rotatable":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000}}}}
2017-12-17 23:30:51 INFO Selenium Detected W3C dialect.
2017-12-17 23:30:51 INFO Selenium -> POST session/744bd9ae-4cfd-48a7-98e7-86ba7b328df0/url
2017-12-17 23:30:51 INFO Selenium    >>> http://127.0.0.1:4444/session/744bd9ae-4cfd-48a7-98e7-86ba7b328df0/url | {"url":"http://localtest2/Test.html"}
2017-12-17 23:30:51 DEBUG Selenium      > {"Accept"=>"application/json", "Content-Type"=>"application/json; charset=utf-8", "Content-Length"=>"37"}
1513575051227	webdriver::server	DEBUG	-> POST /session/744bd9ae-4cfd-48a7-98e7-86ba7b328df0/url {"url":"http://localtest2/Test.html"}
1513575051228	geckodriver::marionette	TRACE	-> 49:[0,2,"get",{"url":"http://localtest2/Test.html"}]
1513575051230	Marionette	TRACE	0 -> [0,2,"get",{"url":"http://localtest2/Test.html"}]
1513575051233	Marionette	DEBUG	Received DOM event "beforeunload" for "about:blank"
1513575066166	Marionette	DEBUG	Received DOM event "pagehide" for "about:blank"
1513575066175	Marionette	DEBUG	Received DOM event "DOMContentLoaded" for "http://localtest2/Test.html"
1513575066534	Marionette	DEBUG	Received DOM event "pageshow" for "http://localtest2/Test.html"
1513575066540	Marionette	TRACE	0 <- [1,2,null,{}]
1513575066559	geckodriver::marionette	TRACE	<- [1,2,null,{}]
1513575066560	webdriver::server	DEBUG	<- 200 OK {"value": {}}
2017-12-17 23:31:06 INFO Selenium <- {"value": {}}
2017-12-17 23:31:11 INFO Selenium -> POST session/744bd9ae-4cfd-48a7-98e7-86ba7b328df0/element
2017-12-17 23:31:11 INFO Selenium    >>> http://127.0.0.1:4444/session/744bd9ae-4cfd-48a7-98e7-86ba7b328df0/element | {"using":"css selector","value":"a"}
2017-12-17 23:31:11 DEBUG Selenium      > {"Accept"=>"application/json", "Content-Type"=>"application/json; charset=utf-8", "Content-Length"=>"36"}
1513575071566	webdriver::server	DEBUG	-> POST /session/744bd9ae-4cfd-48a7-98e7-86ba7b328df0/element {"using":"css selector","value":"a"}
1513575071567	geckodriver::marionette	TRACE	-> 56:[0,3,"findElement",{"using":"css selector","value":"a"}]
1513575071570	Marionette	TRACE	0 -> [0,3,"findElement",{"using":"css selector","value":"a"}]
1513575071576	Marionette	TRACE	0 <- [1,3,null,{"value":{"element-6066-11e4-a52e-4f735466cecf":"7de31886-72c0-4086-92aa-49c86704f1c2","ELEMENT":"7de31886-72c0-4086-92aa-49c86704f1c2"}}]
1513575071575	geckodriver::marionette	TRACE	<- [1,3,null,{"value":{"element-6066-11e4-a52e-4f735466cecf":"7de31886-72c0-4086-92aa-49c86704f1c2","ELEMENT":"7de31886-72c0-4086-92aa-49c86704f1c2"}}]
1513575071575	webdriver::server	DEBUG	<- 200 OK {"value":{"element-6066-11e4-a52e-4f735466cecf":"7de31886-72c0-4086-92aa-49c86704f1c2"}}
2017-12-17 23:31:11 INFO Selenium <- {"value":{"element-6066-11e4-a52e-4f735466cecf":"7de31886-72c0-4086-92aa-49c86704f1c2"}}
2017-12-17 23:31:11 INFO Selenium -> POST session/744bd9ae-4cfd-48a7-98e7-86ba7b328df0/element/7de31886-72c0-4086-92aa-49c86704f1c2/click
1513575071579	webdriver::server	DEBUG	-> POST /session/744bd9ae-4cfd-48a7-98e7-86ba7b328df0/element/7de31886-72c0-4086-92aa-49c86704f1c2/click {}
1513575071580	geckodriver::marionette	TRACE	-> 66:[0,4,"clickElement",{"id":"7de31886-72c0-4086-92aa-49c86704f1c2"}]
1513575071582	Marionette	TRACE	0 -> [0,4,"clickElement",{"id":"7de31886-72c0-4086-92aa-49c86704f1c2"}]
1513575071591	Marionette	TRACE	0 <- [1,4,{"error":"element not interactable","message":"Element <a id=\"bcd\" href=\"https://www.google.com/\"> could not be scro ... avigate@chrome://marionette/content/listener.js:409:13\nclickElement@chrome://marionette/content/listener.js:1309:5\n"},null]
1513575071590	geckodriver::marionette	TRACE	<- [1,4,{"error":"element not interactable","message":"Element <a id=\"bcd\" href=\"https://www.google.com/\"> could not be scrolled into view","stacktrace":"WebDriverError@chrome://marionette/content/error.js:172:5\nElementNotInteractableError@chrome://marionette/content/error.js:280:5\nwebdriverClickElement@chrome://marionette/content/interaction.js:159:11\ninteraction.clickElement@chrome://marionette/content/interaction.js:130:11\nclickElement/<@chrome://marionette/content/listener.js:1310:14\nnavigate/<@chrome://marionette/content/listener.js:410:13\nnavigate@chrome://marionette/content/listener.js:409:13\nclickElement@chrome://marionette/content/listener.js:1309:5\n"},null]
1513575071590	webdriver::server	DEBUG	<- 400 Bad Request {"value":{"error":"element not interactable","message":"Element <a id=\"bcd\" href=\"https://www.google.com/\"> could not be scrolled into view","stacktrace":"WebDriverError@chrome://marionette/content/error.js:172:5\nElementNotInteractableError@chrome://marionette/content/error.js:280:5\nwebdriverClickElement@chrome://marionette/content/interaction.js:159:11\ninteraction.clickElement@chrome://marionette/content/interaction.js:130:11\nclickElement/<@chrome://marionette/content/listener.js:1310:14\nnavigate/<@chrome://marionette/content/listener.js:410:13\nnavigate@chrome://marionette/content/listener.js:409:13\nclickElement@chrome://marionette/content/listener.js:1309:5\n"}}
2017-12-17 23:31:11 INFO Selenium <- {"value":{"error":"element not interactable","message":"Element <a id=\"bcd\" href=\"https://www.google.com/\"> could not be scrolled into view","stacktrace":"WebDriverError@chrome://marionette/content/error.js:172:5\nElementNotInteractableError@chrome://marionette/content/error.js:280:5\nwebdriverClickElement@chrome://marionette/content/interaction.js:159:11\ninteraction.clickElement@chrome://marionette/content/interaction.js:130:11\nclickElement/<@chrome://marionette/content/listener.js:1310:14\nnavigate/<@chrome://marionette/content/listener.js:410:13\nnavigate@chrome://marionette/content/listener.js:409:13\nclickElement@chrome://marionette/content/listener.js:1309:5\n"}}
1513575071614	Marionette	DEBUG	Closed connection 0
WebDriverError@chrome://marionette/content/error.js:172:5: Element <a id="bcd" href="https://www.google.com/"> could not be scrolled into view (Selenium::WebDriver::Error::ElementNotInteractableError)
	from ElementNotInteractableError@chrome://marionette/content/error.js:280:5
	from webdriverClickElement@chrome://marionette/content/interaction.js:159:11
	from interaction.clickElement@chrome://marionette/content/interaction.js:130:11
	from clickElement/<@chrome://marionette/content/listener.js:1310:14
	from navigate/<@chrome://marionette/content/listener.js:410:13
	from navigate@chrome://marionette/content/listener.js:409:13
	from clickElement@chrome://marionette/content/listener.js:1309:5
	from C:/Ruby24/lib/ruby/gems/2.4.0/gems/selenium-webdriver-3.8.0/lib/selenium/webdriver/remote/response.rb:69:in `assert_ok'
	from C:/Ruby24/lib/ruby/gems/2.4.0/gems/selenium-webdriver-3.8.0/lib/selenium/webdriver/remote/response.rb:32:in `initialize'
	from C:/Ruby24/lib/ruby/gems/2.4.0/gems/selenium-webdriver-3.8.0/lib/selenium/webdriver/remote/http/common.rb:81:in `new'
	from C:/Ruby24/lib/ruby/gems/2.4.0/gems/selenium-webdriver-3.8.0/lib/selenium/webdriver/remote/http/common.rb:81:in `create_response'
	from C:/Ruby24/lib/ruby/gems/2.4.0/gems/selenium-webdriver-3.8.0/lib/selenium/webdriver/remote/http/default.rb:104:in `request'
	from C:/Ruby24/lib/ruby/gems/2.4.0/gems/selenium-webdriver-3.8.0/lib/selenium/webdriver/remote/http/common.rb:59:in `call'
	from C:/Ruby24/lib/ruby/gems/2.4.0/gems/selenium-webdriver-3.8.0/lib/selenium/webdriver/remote/bridge.rb:164:in `execute'
	from C:/Ruby24/lib/ruby/gems/2.4.0/gems/selenium-webdriver-3.8.0/lib/selenium/webdriver/remote/w3c/bridge.rb:535:in `execute'
	from C:/Ruby24/lib/ruby/gems/2.4.0/gems/selenium-webdriver-3.8.0/lib/selenium/webdriver/remote/w3c/bridge.rb:358:in `click_element'
	from C:/Ruby24/lib/ruby/gems/2.4.0/gems/selenium-webdriver-3.8.0/lib/selenium/webdriver/common/element.rb:72:in `click'
	from C:/Code/sn/svn1/clients/Testing/Test_001.rb:23:in `<top (required)>'
	from -e:1:in `load'
	from -e:1:in `<main>'

@lock
Copy link

lock bot commented Aug 17, 2019

This issue has been automatically locked since there has not been any recent activity after it was closed. If you have run into an issue you think is related, please open a new issue.

@lock lock bot locked and limited conversation to collaborators Aug 17, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants