简体   繁体   English

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

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

I am in the process of automating my test using selenium. 我正在使用硒自动化我的测试。 I am currently unable to click on the image button. 我目前无法点击图片按钮。 Please see the code below 请参阅下面的代码

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

I am using the code below to identify the element and click. 我使用下面的代码来识别元素并单击。

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

Not sure what the problem is. 不确定是什么问题。 Could somebody help ? 有人可以帮忙吗?

Try //input not //img . 尝试//input不是//img Other than that, your XPath should be fine 除此之外,你的XPath应该没问题

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM