Skip to content
This repository has been archived by the owner on Dec 18, 2019. It is now read-only.

single quotes sometimes converted to double quotes? #19

Open
christian-bromann opened this issue Feb 25, 2019 · 5 comments
Open

single quotes sometimes converted to double quotes? #19

christian-bromann opened this issue Feb 25, 2019 · 5 comments

Comments

@christian-bromann
Copy link
Contributor

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:

An element could not be located on the page using the given search parameters.
Error: An element could not be located on the page using the given search parameters.
at click("input[name="enable_Selector With Spaces"][value=yes]") - at element("input[name="enable_Selector With Spaces"][value=yes]") - click.js:12:17

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:

browser.click(`input[name="enable_Selector With Spaces"][value=yes]`)

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.

"webdriverio": "^4.14.0",
"wdio-cucumber-framework": "^2.2.7",
"wdio-chromedriver-service": "^0.1.3",

Copied from original issue: webdriverio/webdriverio#3109

@christian-bromann
Copy link
Contributor Author

Can you provide some logs please?

@christian-bromann
Copy link
Contributor Author

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.

@christian-bromann
Copy link
Contributor Author

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?

@christian-bromann
Copy link
Contributor Author

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.

@christian-bromann
Copy link
Contributor Author

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.

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

1 participant