简体   繁体   中英

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 . Other than that, your XPath should be fine

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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