0

Please help to improve my code. I use JUnit and PageObjectPattern.

I need to:

  • in area find email that contains String ("Test"), test fails if email not found
  • click on this email and find there Text ("Success")

Page:

@FindBy(className = "123")
    WebElement area;

@FindBy(xpath = "//*[contains(text(), 'Test')]")
    WebElement email;

public String findText(){
    return area.getText();
}

public void clickEmail(){
    email.click();
}

Test:

@Test
public void goTest() {
    home = new Home(driver);
    Assert.assertTrue("Failed", home.findText().contains("Test"));
    home.clickEmail();
    assertTrue(home.getElement().contains("Success"));
}

I get an error: org.openqa.selenium.ElementNotVisibleException: element not visible

  • Possible duplicate of [Selenium \[Java\] PageFactory Design : Where do I write my Assertions following Page Object Model](https://stackoverflow.com/questions/43017058/selenium-java-pagefactory-design-where-do-i-write-my-assertions-following-pa) – undetected Selenium Mar 09 '18 at 12:04
  • I improved my code, but that is not I am lookin for. – Happy happy Mar 09 '18 at 12:42
  • @Happyhappy And what do you expect? You already wrote Assertions you are looking for. – Fenio Mar 09 '18 at 13:11
  • I expect to get right code. Now I get error message org.openqa.selenium.ElementNotVisibleException: element not visible – Happy happy Mar 09 '18 at 13:30

0 Answers0