1

I need to find the value thats inside the 2nd paragraph text value

var id3 = driver.FindElement(By.XPath("//div[contains(@class, 'col-xs-2 item-data-block')]/p[text()='Id. 3']")).Text;
Console.WriteLine(id3);
<div class="col-xs-2 item-data-block">
<p class="tab">Id. 3</p>
<p>A09999999</p>
</div>

Because my webpage have +12 classes with the same name, I also need to use the paragraph text value as an searching attribute. But I dont know how to get the 2nd paragraph value. Ive provided what Ive done... Thanks.

1 Answers1

1

The .NET WebDriver class has a FindElements method that returns a read only collection of IWebElement objects. You can build a two step search with this method.

Another solution is described in XPath with multiple conditions

In your case it should be

"//div[@class='col-xs-2 item-data-block' and ./p/text()='Id. 3']"
Jens Dibbern
  • 1,434
  • 2
  • 13
  • 20