How to use unicode inside an xpath string? (UnicodeEncodeError)
Posted
by Gj
on Stack Overflow
See other posts from Stack Overflow
or by Gj
Published on 2010-06-12T19:36:35Z
Indexed on
2010/06/12
19:42 UTC
Read the original article
Hit count: 378
I'm using xpath in Selenium RC via the Python api.
I need to click an a element who's text is "Submit »"
Here's the error that I'm getting:
In [18]: sel.click(u"xpath=//a[text()='Submit \xbb')]")
ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (1121, 0))
---------------------------------------------------------------------------
Exception Traceback (most recent call last)
/Users/me/<ipython console> in <module>()
/Users/me/selenium.pyc in click(self, locator)
282 'locator' is an element locator
283 """
--> 284 self.do_command("click", [locator,])
285
286
/Users/me/selenium.pyc in do_command(self, verb, args)
213 #print "Selenium Result: " + repr(data) + "\n\n"
214 if (not data.startswith('OK')):
--> 215 raise Exception, data
216 return data
217
<type 'str'>: (<type 'exceptions.UnicodeEncodeError'>, UnicodeEncodeError('ascii', u"ERROR: Invalid xpath [2]: //a[text()='Submit \xbb')]", 45, 46, 'ordinal not in range(128)'))
© Stack Overflow or respective owner