Open christian-bromann opened 5 years ago
Can you provide some logs please?
From @worc on December 13, 2018 19:45
i ran into the issue again today, and it's a red herring more than anything else. in the source code for the step definitions i have a selector that uses either single quotes or backticks:
browser.click(`input[name="enable_Selector With Spaces"][value=yes]`)
but if that element can't be clicked then the error printed to the command line makes it look like the quotes were converted incorrectly. so i'm looking at this error message thinking yeah, if you don't have your quotes setup correctly you're not going to find an element with those parameters:
An element could not be located on the page using the given search parameters
browser.click("input[name="enable_Selector With Spaces"][value=yes]")
but in actuality, i was missing a waitForVisible
, the element hadn't loaded yet. which of course has the maddening side effect where if you put a debug point before the problematic selector, the element will load in time and the error seems to go away.
i'm not sure if the double quotes are really what the driver is using or if it's a bad conversion when the error message is prepped for the logs. some clarity around that would be nice.
From @abjerstedt on December 13, 2018 21:3
@worc as a side note, i highly recommend you make a custom command that wrappers click and makes sure that you wait for the element to be at a minimum visible, and probably also enabled before any click.
On this topic, since you determined that the issue has nothing to do with escaping, are we good to close this?
From @worc on December 13, 2018 23:50
@abjerstedt that sounds like an anti-pattern and trying to hammer everything into a nail. not every part of a step definition is going to require a waitForVisible
.
and i think there's still an issue standing here with the logging providing misleading values back to a dev.
From @abjerstedt on February 25, 2019 22:3
@christian-bromann Is this worth keeping open? It seems a little like overkill to have to run a regex on all dumps of the selector property.
From @worc on December 8, 2018 0:1
i don't even know on this one. i have an attribute selector with characters that break the underlying query (spaces and slashes in this case), so i wrapped the selector in double quotes and the full query in single quotes:
browser.click('input[name="enable_Selector With Spaces"][value=yes]')
and periodically the test would error out with this message:
which at first glance seems like the single quotes around the full query are being converted to double quotes? i wasn't sure how to verify that, so i did the next best thing and changed the single quotes to backticks:
at that point the error cleared up. but just to verify the issue, i switched the backticks back to single quotes, but the error no longer occurs. i'm thinking i probably just missed something juggling all those quotes and brackets, but figured i'd at least write down the weird thing i saw in case someone else encounters it.
Copied from original issue: webdriverio/webdriverio#3109