mercredi 1 août 2018

No such element: Unable to locate element: exception coming in selenium

I am getting below error every time when trying to verify the user credentials after login.

org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":"//td[contains(text(), 'User: Naveen K')]"}

My code is as follows

Home page test class

@Test(priority = 2)
public void verifyUserNameLabelTest() {

    testUtil.switchToFrame();       

    Assert.assertTrue(homePage.verifyUserName());

}

TestUtil class

public void switchToFrame() {

    driver.switchTo().frame("mainpanel");

}

Home page class

public boolean verifyUserName() {

    return usernameLabel.isDisplayed();

} 

My HTML web page source code is as follows

enter image description here

Aucun commentaire:

Enregistrer un commentaire