Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Webdriver (c#) - find button presumably by text

I'm struggling to get a handle on a button. Would anyone be able to point me in the right direction on how to get a handle on the button AND click on it using xpath or a css selector? Here is the code:

 <button class="trans-button mtrn-dialog-button" title="" value="">OK</button>

I have tried to get it by text. It seems to work fine (in that it can find the element) but it doesn't seem to want to provide the click event to the button

like image 912
Banjaxx Avatar asked Oct 29 '25 06:10

Banjaxx


1 Answers

Using the following Xpath expression (Inner Text) should allow you click the button

 IWebELement okButton = aDriver.FindElement(By.XPath("//button[.='OK']"));
like image 116
Zach Avatar answered Oct 31 '25 13:10

Zach