javascript - org.openqa.selenium.WebDriverException: unknown error: Runtime.evaluate threw exception: SyntaxError: missing ) after argument list -


i working on selenium webdriver , need enter text without using sendkeys method, because search popup text field hidden. wrote below code:

1st way:

((javascriptexecutor)driver).executescript("document.getelementbyxpath('//input[@class='form-control input-small input-inline']').value='textvalue'"); 

2nd way:

javascriptexecutor jse = (javascriptexecutor) driver; //jse.executescript("document.getelementbyxpath('//input[@class='form-control input-small input-inline']').value ='abcd';"); 

3rd way:

javascriptexecutor executor = (javascriptexecutor)driver; executor.executescript("arguments[0].type ='search';",chemobject.getsearchpopup()); 

but getting syntax error mentioned in title.

your first 1 producing javascript error, , reason mixed-up single quotes, wouldn't have seen java code, not until js executed.

the simplest fix replace:

((javascriptexecutor)driver).executescript("document.getelementbyxpath('//input[@class='form-control input-small input-inline']').value='textvalue'");

with:

((javascriptexecutor)driver).executescript("document.getelementbyxpath(\"//input[@class='form-control input-small input-inline']\").value='textvalue'");

however, still won't work (nor second attempt), because getelementbyxpath isn't javascript dom method.

this covered in very similar thread here.


Comments

Popular posts from this blog

Unlimited choices in BASH case statement -

Redirect to a HTTPS version using .htaccess -

javascript - jQuery: Add class depending on URL in the best way -