lundi 8 février 2021

How to make test script wait for few second until the page elements are loaded fully in java-selenium?

I have a SignIn button in the homepage. As I click that using test script it moves to a new page(on same tab) for signup where I have to click of another button for login using email id and password. If I am using Thread.sleep(1000) then before clicking on the loginbyemail button then only the script is working fine but without thread.sleep if i use any other wait method(Implicit, explicit, fluent) nothing is working and script is not able to click on loginbyemail button and failing with an no such element: Unable to locate element.

Additionally : Java_scripts are taking around 1.24 seconds or more to load.

WebElement SignIn = po.HomePageSignIn();
    a.moveToElement(SignIn).click().build().perform();
    Thread.sleep(1000);
    WebElement loginbyEmailid = po.loginbyEmailid();
    w.until(ExpectedConditions.visibilityOf(loginbyEmailid));
    w.until(ExpectedConditions.elementToBeClickable(loginbyEmailid));
    a.moveToElement(loginbyEmailid).click().build().perform();

Aucun commentaire:

Enregistrer un commentaire