Selenium test go too fast and redirect to next page before clicking on element
I have the following test : login with multiple users loaded from excel file and create multiple persons which is also loaded from excel file
the problem I meet is that the test goes to create-person page before the login done but when setting Thread.sleep(1000) the test passed
for more clarification here is my code below
@Given("user logged in and populates the form and click create and logout")
public void user_logged_in_and_populates_the_form_and_click_create_and_logout() throws InterruptedException {
userLoginCreationPage.init();
logger.info("**************************************** init the driver && go to login page http://localhost:4200/login");
for (UserLoginPageData userLoginPageData : userLoginPageDataList) {
logger.info("Line " + userLoginPageData.getRowIndex() + "from Excel file");
userLoginCreationPage.enterUsername(userLoginPageData.getUsername());
userLoginCreationPage.enterPassword(userLoginPageData.getPassword());
userLoginCreationPage.clickOnLogin();
Thread.sleep(500);
logger.info(userLoginPageData.toString() + "is login");
personCreationPage.init();
logger.info("**************************************** init the driver && go to creation page http://localhost:4200/dossier-person/new");
for (PersonPageData personPageData : personPageDataList) {
if (userLoginPageData.getIdUser().equals(personPageData.getIdUser())) {
personCreationPage.refresh();
personCreationPage.enterUsername(personPageData.getUsername());
personCreationPage.enterEmail(personPageData.getEmail());
personCreationPage.enterPassword(personPageData.getPassword());
personCreationPage.clickTab();
personCreationPage.clickOnCreate();
logger.info(personPageData.toString() + " **************************************** is created by " + userLoginPageData.getUsername());
}
}
userLoginCreationPage.clickOnLogout();
}
}
Aucun commentaire:
Enregistrer un commentaire