1
js.executeScript("document.querySelector('input[name='password']');");

This line is throwing the following Exception in thread:

"main" org.openqa.selenium.WebDriverException: missing ) after argument list

3 Answers 3

1

Try the following code.

js.executeScript("document.querySelector('input[name=\'password\']')");
Sign up to request clarification or add additional context in comments.

2 Comments

No luck,still its not working. while //driver.findElement(By.cssSelector("input[name='password']"‌​)).sendKeys("gamb"); is working fine .but js.executeScript("document.querySelector('input[name=\'pas‌​sword\']').value='ga‌​mb'"); is not working
you can try with document.querySelector('input[name=\'pas‌sword\']').setAttribute('value','gamb');
0

Try

js.executeScript("document.querySelector('input[name='password']')");

Let me know if this Answers your Question.

1 Comment

No luck,still its not working. while //driver.findElement(By.cssSelector("input[name='password']")).sendKeys("gamb"); is working fine .but js.executeScript("document.querySelector('input[name=\'password\']').value='gamb'"); is not working
0

You can try one of the following

js.executeScript("document.querySelector(\'input[name=\'password\']\');");
js.executeScript("document.querySelector(\"input[name='password']\");");

Although in your comments you added this line

js.executeScript("document.querySelector('input[name=\'pas‌​‌​sword\']').value='ga‌​‌​mb'");

Which wouldn't work because if you look at .value you'll need to escape your .value setting as well more than likely.

Given that I don't have access to your site or your code, I would suggest that you test to make sure your javascript is valid for your page. One way to do so would be to take the javascript itself (everything insdie the .executeScript) and run it through your browsers dev tools console or script execution window.

If the value sets using the browsers dev tools, great...issue is with selenium. If the value does not set using browser dev tools...you'll need to refactor your javascript as the problem is likely not with selenium, rather your JS selector more than likely.

Although, the following, from your comment, works...you may not need to execute it via javascript.

driver.findElement(By.cssSelector("input[name='password']"‌​‌​)).sendKeys("gamb"‌​);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.