Reputation: 441
I am trying to find the xpath of a dynamic element. Entering the below xpath returns 10 elements.
//div[contains(@class,'gallery_grid_image_caption
gallery_grid_image_caption_padding')]/p
One of the those elements has a text called 'Add Category'.
<div class="gallery_grid_item md-card-content">
<div class="gallery_grid_image_caption gallery_grid_image_caption_padding">
<div class="gallery_grid_image_menu" />
<p class="uk-text-truncate uk-text-upper uk-text-center add_category">Add category</p>
</div>
</div>
I want to select this element and click on that.
So I tried the below:
//div[contains(@class,'gallery_grid_image_caption gallery_grid_image_caption_padding')]/p[contains(text()='Add Category')]
But it's not returning the element.
Please advice as to where i am going wrong?
Upvotes: 1
Views: 121
Reputation: 52665
Please try this XPath
:
//p[text()="Add category"]
P.S. Please note that contains
used in this way:
//p[contains(text(),'Add category')]
Upvotes: 1