Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find div Element without an id attribute with Selenium Webdriver

I'm using C# and Selenium Webdriver and I'm trying to find a div Element in my html code which looks like this:

<div class="x-grid-cell-inner" style="text-align: left;" unselectable="on">
    phys_tag_desc
</div>

I cant find a method to search for the value of the div Element with Selenium Webdriver. I already searched this site and checked the Selenium Webdriver Documentation, but couldn't find anything.

like image 736
user3292642 Avatar asked Nov 22 '25 18:11

user3292642


1 Answers

Well if text value is unique, then solution is simple. Try the xpath below:

//div[text()='phys_tag_desc']

If the text is not exact match. Try following:

//div[contains(text(),'phys_tag_desc')]
like image 173
Husam Avatar answered Nov 24 '25 07:11

Husam



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!