lundi 8 mars 2021

sendkeys not working when using javascript executor in selenium test

I am trying to send-keys using javascript executor, my test script is shown below. I can see the right username and password entered into the form box, but somehow when I click login it doesn't log in. I am pretty sure that these are the correct sign-on parameters and work perfectly fine manually. I did use both ways to click submit button, javascript and slenium way

    JavascriptExecutor je = (JavascriptExecutor) webDriver;
    je.executeScript("document.getElementById('userid').value='username'");
    je.executeScript("document.getElementById('password').value='password'");
    # je.executeScript("document.getElementById('Submit').click()");
    webDriver.findElement(By.id("Submit")).click();

Aucun commentaire:

Enregistrer un commentaire