Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selenium - Finding element that has title

I have the following element:

<button class="k-button k-button-icontext min-button-width" title="Add Matter (Access key + A)" onclick="addMatterToBill();return false;" accesskey="a">
<u>A</u>
dd Matter

How can I locate that element using c#? I have tried the following:

Driver.FindElement(By.Xpath("//input[@title= 'Add Matter (Access key + A)']") 

and that did not work. I am not an expert at Xpath, so I better read/learn about it.

The actual text on the button is: Add Matter which is found in the above html between the <u>.

Any help will be more welcome.

like image 795
Patrick Avatar asked Sep 24 '15 13:09

Patrick


1 Answers

The target element is a button, not an input:

//button[@title = 'Add Matter (Access key + A)']

You may also check the title attribute with starts-with():

//button[starts-with(@title, 'Add Matter')]
like image 109
alecxe Avatar answered Sep 29 '22 19:09

alecxe