'Add to cart button not working, Selenium C# element not interactable
I am automating below website, Add to cart button is not working: http://automationpractice.com
Please use below id pass to login: ID : [email protected] Password : Pass123##
By addCartTshirt = By.XPath("//*[contains(text(),'Add to cart')]");
public void Add_To_Cart_T_Shirt()
{
driver.FindElement(addCartTshirt).Click();
}
Solution 1:[1]
You can use action method to do it, I checked the below in Java
and it's working for me.
Actions action = new Actions(driver);
element = driver.FindElement(By.Xpath("//img[@title='Faded Short Sleeve T-shirts']"))
action.moveToElement(element).perform();
ele = driver.FindElement(By.Xpath("//a[@title='Add to cart']"));
action.moveToElement(ele).click().perform();
do not forget to import
import org.openqa.selenium.interactions.Actions
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Akzy |