我正在努力掌握一个按钮。谁能指出我正确的方向如何获得按钮的句柄并使用 xpath 或 css 选择器单击它?这是代码:
<button class="trans-button mtrn-dialog-button" title="" value="">OK</button>
我试图通过文字得到它。它似乎工作正常(因为它可以找到元素)但它似乎不想为按钮提供点击事件
最佳答案
Using the following Xpath expression (Inner Text) should allow you click the button
IWebELement okButton = aDriver.FindElement(By.XPath("//button[.='OK']"));
关于selenium - Webdriver (c#) - 可能通过文本查找按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37304084/