Home > Software engineering >  Add to cart button not working, Selenium C# element not interactable
Add to cart button not working, Selenium C# element not interactable

Time:05-18

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();
    }

CodePudding user response:

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
  • Related