"WebDriver:FindElement" cannot find anchors for data URLs whose href attribute contain a hash (not encoded)
Categories
(Remote Protocol :: Marionette, defect, P3)
Tracking
(Not tracked)
People
(Reporter: whimboo, Unassigned)
Details
(Keywords: hang)
The following Marionette test hangs in WebDriver:FindElement
because of the hash in the href attribute:
def test_hang_find_element(self):
self.marionette.navigate(inline("""<a href="#">click me</a>"""))
link = self.marionette.find_element(By.TAG_NAME, "a")
When the hash gets removed it works all fine.
Reporter | ||
Comment 1•5 years ago
|
||
There is actually no hang. By accident I had the implicit timeout set to a high value, and as such the command never returned.
The underlying reason here is that the anchor never gets added to the DOM when the href
attribute contains the hash. It can be verified by using the following data URL:
data:text/html;charset=utf-8,<a href=\"#\">click me</a>"
Olli, is that a bug in Firefox or somewhat expected due to the usage of the data URL?
Comment 2•5 years ago
|
||
The part after # is fragment identifier.
See what location.hash looks like in that document.
You may need to use an entity for #. (# or # or some such)
Comment 3•5 years ago
|
||
The severity field is not set for this bug.
:whimboo, could you have a look please?
For more information, please visit auto_nag documentation.
Reporter | ||
Comment 4•5 years ago
|
||
(In reply to Olli Pettay [:smaug] from comment #2)
The part after # is fragment identifier.
See what location.hash looks like in that document.
There is no difference. With the hash sign included the click me
anchor text is even not displayed. Just open the this URL in Firefox:
data:text/html;charset=utf-8,<a href="#foo">click me</a>
Once you remove the has and leave foo
, the anchor text is displayed.
Comment 5•5 years ago
|
||
Everything after # in the data url is part of the fragment identifier.
perhaps
data:text/html;charset=utf-8,<a href="%23foo">click me</a>
Reporter | ||
Comment 6•5 years ago
|
||
Ok, so correctly encoding the data URL fixes the Marionette testcase for me. There is actually also no hang. It only happened because I had an implicit wait set by accident.
When using the not encoded URL, the a
tag isn't closed correctly, and as such Firefox also doesn't add it to the DOM. So the behavior of Marionette is correct here. Closing as invalid.
Updated•2 years ago
|
Description
•