I am encountering an issue with something. I am working on two equations within . The first equation is 2+2 and I validate it, then the second equation is 3+3 and I validate that as well.
The validation for the first equation is successful and I use the following code snippet:
WebElement element = driver.findElement(By.xpath("/html/body/div[3]/div[3]/ul/li[1]/p[1]"));
String title = element.getAttribute("title");
System.out.println(title);
Assert.assertEquals(title, "4");
This test passes without any issues.
However, for the second equation, I cannot reuse the xpath mentioned above because it still refers to the value 4.
Any suggestions on how to approach this?
Here is the code snippet provided:
<ul>
<li>
<p title="6" class="r">= 6</p>
<p data-inp="3+3" title="3+3" class="l">3+3</p>
</li>
<li>
<p title="4" class="r">= 4</p>
<p data-inp="2+2" title="2+2" class="l">2+2</p>
</li>
</ul>
I intend to locate the element with "title=6" to perform assertion on the equation.