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

hover with XPath (can single quotes be used in XPath?) #306

Closed
stevzie opened this issue Nov 5, 2018 · 6 comments
Closed

hover with XPath (can single quotes be used in XPath?) #306

stevzie opened this issue Nov 5, 2018 · 6 comments
Labels

Comments

@stevzie
Copy link

stevzie commented Nov 5, 2018

Can anyone explain why the following does not work:

hover //tr[contains(@id, 'user')]/td[1]/strong/a

I receive:
SyntaxError: Expected token ')'

The XPath statement works correctly in the Chrome console.

@kensoh
Copy link
Member

kensoh commented Nov 6, 2018

Hey @stevzie try using double quotes -

hover //tr[contains(@id, "user")]/td[1]/strong/a

The flow samples and the tip under here - https://github.com/kelaberetiv/TagUI#steps-description mentions this but may be easy to miss.

The convention is chosen so that users can use single quotes to form dynamic XPaths with their variables, eg by user '+variable_name+' or `variable_name` in their element identifiers.

@kensoh kensoh changed the title hover with XPath hover with XPath (can single quotes be used in XPath?) Nov 6, 2018
@kensoh kensoh added the query label Nov 6, 2018
@kensoh
Copy link
Member

kensoh commented Nov 6, 2018

Forgot to copy @Aussiroth who is now maintaining TagUI for AI Singapore -

@fez226
Copy link

fez226 commented Feb 21, 2019

hello @kensoh i had a problem with single quote but i finally have a solution... if anybody want to put a single quote on a string you need to put a back slash behind it. example:

var1 = single quote + \ + single quote + STRING + \ + single quote + single quote

type [element] as '+var1+'

so this write 'STRING' on the element input text

@kensoh
Copy link
Member

kensoh commented Feb 24, 2019

cool stuff thanks @fez226 fo sharing! yes I normally recommend using double quotes to keep it syntactically correct but yes you can use \ to escape the single quote character in XPath string.

also, now TagUI supports backticks to denote variable, so your example step can be written as

type element_identifier as `var1`

@maheswarGR
Copy link

maheswarGR commented Feb 1, 2022

hover xpath not working : @kensoh

hover //*[@id="gatewayHistoryDetailsTab"]/div[1]/i[3]

@kensoh
Copy link
Member

kensoh commented Feb 3, 2022

I saw the duplicated question here - #1171 (comment) and will reply there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants