Reputation: 107
I am using Python in selenium to create scripts. When used the below code getting syntax error. I could find that the issue is with the registered trademark symbol '®' in title. Please help me out of this.
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Firefox()
driver.get('https://advance.lexis.com')
assert 'Lexis Advance® Sign In | LexisNexis' in driver.title
Upvotes: 1
Views: 12129
Reputation: 1
That means you are using a character that your editor can't read or accept. I am writing a secret language program and I used .replace()
to edit the text.
I used the ❊
character, and I had the same error! But I replaced it with another character, and now I have no problem.
Upvotes: 0
Reputation: 393
If you are using Python 3 and Pydev in Eclipse an alternate solution would be to change the file encoding to utf-8 in the properties as shown below. Just right click on the file, go to properties and change the encoding to utf-8
Upvotes: 2
Reputation: 12214
The content of your question is fine: I inspected it to see that StackOverflow provides the ® symbol encoded as UTF-8.
Based on the error message in the title, Python is reading the file as UTF-8 but I suspect that your editor is using a different encoding to save the file.
Perhaps it is using ISO 8859-1 (aka 'latin1'), or something else. ISO 8859-1 defines the byte 0xAE as the registered trademark symbol. Unicode also defines code point U+00AE as the registered trademark symbol.
You have two solutions:
# encoding: foo
at the top of your fileUpvotes: 2