无法在 C# 中使用 selenium web 驱动程序单击图像按钮

Not able to click the image button using selenium web driver in C#

我正在使用 selenium 自动化我的测试。我目前无法点击图像按钮。请看下面的代码

<input name="op-DPChoose-MAESTRO^SSL" type="image" src="/images/logos/MAESTRO.gif" alt="Maestro">

我正在使用下面的代码来识别元素并单击。

driver.FindElement(By.XPath("//img[@src ='/images/logos/MAESTRO.gif' and @alt='Maestro']")).Click();

不确定是什么问题。有人可以帮忙吗?

尝试 //input 而不是 //img。除此之外,您的 XPath 应该没问题

driver.FindElement(By.XPath("//input[@src ='/images/logos/MAESTRO.gif' and @alt='Maestro']")).Click();