selenium SyntaxError: Unexpected identifier 错误

在使用selenium 时触发该错误的原因

selenium.common.exceptions.WebDriverException: Message: unknown error: Runtime.evaluate threw exception: SyntaxError: Unexpected identifier

例子:

css_a = ''
driver.execute_script(
    "document.getElementById('{id}').outerHTML = '{content}';".format(id="vehicleLicenseCodeId", content=css_a))

注意被标红的双引号,应该切换成单引号就能解决该错误,单引号换成双引号

 

 

 

你可能感兴趣的:(python,selenium)