Search code examples
javaseleniumselenium-webdrivertestngassert

Assert in selenium in not working for me


'Assert cannot be resolved' is displayed when i tries to insert an Assert command

    String menu1 = driver.findElement(By.xpath("value")).getText();
    System.out.println(menu1);
    if(Assert.assertEquals(menu1,"About Us"))
    {

    }

Solution

  • please add the below import statement to your code. it may resolve your issue.

    import org.testng.Assert;
    

    assertEquals doesn't return any value.

    You can't put inside a if clause. please remove if statement.

    just add only the assert statement.

    Assert.assertEquals(menu1,"About Us");