Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

196
Views
NOT able to use javascriptexecutor for clicking on LogIn button (tried querySelector, getElementsByClassName but failed)

I am trying to do Selenium with Java casestudy on the web site https://www.demoblaze.com/index.html,

Steps:

  1. Go to https://www.demoblaze.com/index.html
  2. clcik on 'Log in' and enter username and Password, finally click on Log in button.

Issue:

As findElement is NOT working even with WebDriverWait on the Log In popup, I have tried JavaScriptExecutor which is working fine with Username and Password.

js.executeScript("document.getElementsByTagName('input')[4].value="+"'"+user+"'"); js.executeAsyncScript("document.getElementById('loginpassword').value="+"'"+pass+"'");

However when I tried on Log in button using getElementsByClassName, querySelector, it did not work. Please help.

FYIP: None of the below working for me.

JavascriptExecutor js;

js.executeAsyncScript("arguments[0].click();","document.evaluate('//button[text()='Log in']', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;");

js.executeScript("document.querySelector('button').onclick = 'logIn()'.click();");

js.executeScript("document.getElementsByClassName('btn btn-primary')[2].click()");

about 4 years ago · Santiago Gelvez
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!