Single and Double quotes issue in Xpath

5,183 views
Skip to first unread message

Sakthivel P

unread,
Apr 1, 2013, 7:33:40 AM4/1/13
to robotframe...@googlegroups.com
Hi Experts,

I have question label as (I have question and if you answer as 'yes' you will proceed else will "discontinue" from screen).

How can i take Xpath for this label since it has both single and double quotes in same question.

Xpath expression: //span[text()="I have question and if you answer as 'yes' you will proceed else will "discontinue" from the screen"]

Note: I have to use full question label so i cant use @contains in Xpath.

Please help me out to fix this issue.

Thanks,
Sakthivel P

Markus Bernhardt

unread,
Apr 1, 2013, 7:49:21 AM4/1/13
to sakthi...@gmail.com, robotframe...@googlegroups.com
Hi Sakthivel,

I cant check at the moment, but you try to escape " with \" or "
One of the two should work. Or?

markus

--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.
To post to this group, send email to robotframe...@googlegroups.com.
Visit this group at http://groups.google.com/group/robotframework-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Markus Bernhardt

unread,
Apr 1, 2013, 7:51:04 AM4/1/13
to markus.b...@me.com, sakthi...@gmail.com, robotframe...@googlegroups.com
I buy a "could"...

Kevin O.

unread,
Apr 1, 2013, 9:10:17 AM4/1/13
to robotframe...@googlegroups.com
Unfortunately, there is no escape character in XPath, so you have to use the concat function.
Selenium2Library has a function to handle this, which I used to get a XPath. Try:
//span[text()=concat('I have question and if you answer as ', "'", 'yes', "'", ' you will proceed else will "discontinue" from screen')]

${utils}= Evaluate Selenium2Library.utils Selenium2Library
${escaped xpath}= Call Method ${utils} escape_xpath_value I have question and if you answer as 'yes' you will proceed else will "discontinue" from screen

Kevin

Markus Bernhardt

unread,
Apr 1, 2013, 12:24:44 PM4/1/13
to korm...@gmail.com, robotframe...@googlegroups.com
Ups. Thanks for the correct answer.
Sorry for the noise.

Reply all
Reply to author
Forward
0 new messages