Message: javascript error: missing ) after argument list in execute script

521 Views Asked by At

When I run the following:

self.driver.execute_script("document.getElementByXpath('//input[@id='someid']').value='someValue';

It gives an error

selenium.common.exceptions.JavascriptException: Message:
javascript error: missing ) after argument list
1

There are 1 best solutions below

0
trincot On

You are using the same kind of quote in two different levels of parsing, and so '//input[@id=' is interpreted as one string literal, after which someid is unexpected.

Change:

document.getElementByXpath('//input[@id='someid']')

To:

document.getElementByXpath('//input[@id=\"someid\"]')