I have a navigation bar with 2 links on the right side. When you click one of the link, youre taken to the respective page, and the link will be highlighted. I want to check that this is the case when running my automation test. How can I go about doing this?
The following is my java code
@Test
public void testProductNavBar(){
assertTrue(driver.findElement(By.xpath("/html/body/nav[2]/div/div/ul/li[1]/a")).isSelected());
}
When I run this, the test fails with the following error
java.lang.AssertionError at org.junit.Assert.fail(Assert.java:86)
at org.junit.Assert.assertTrue(Assert.java:41)
at org.junit.Assert.assertTrue(Assert.java:52)
I'm not sure if this is the right way to go about this. Im still new to this so any help is much appreciated!