5

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.

1 Answer 1

6

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')]
Sign up to request clarification or add additional context in comments.

3 Comments

Thanks Abel - Not sure how why I used 'Input' as a target instead of button. The solution worked perfectly fine. Just at the back of it, do you know a proper website where Xpath is well and fully explained along side examples?
Thanks Alecxe for these URLs
@Patrick sure, the last one is SO-specific - just for you to understand the basic concepts and how the QA system works here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.