package flipkart_pack;

import java.util.concurrent.TimeUnit;

import org.openqa..By;
import org.openqa.selenium.;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

public class fp_class {
//public WebDriver driver;

public static void main(String[] args) {

    System.setProperty("webdriver.chrome.driver","E:\chromedriver.exe");

    WebDriver driver=new ChromeDriver();

driver.get(“http://www.amazon.in” );
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(30,TimeUnit.SECONDS);

WebElement eb=driver.findElement(By.xpath(“//[text()=’Shop by’]”));
Actions ob=new Actions(driver);
ob.moveToElement(eb).build().perform();
WebElement eb1=driver.findElement(By.xpath(“//
[@aria-label=’Women’]”));
Actions ob1=new Actions(driver);
ob1.moveToElement(eb1).build().perform();

driver.findElement(By.xpath(“//*[text()=’Handbags & Clutches’]”)).();

driver.findElement(By.xpath(“//[@alt=’wallets’]”)).click();
driver.findElement(By.xpath(“(//
[contains(text(),’Lorna’)])[1]”)).click();
String title1 = driver.findElement(By.xpath(“(//*[contains(text(),’Lorna’)])[1]”)).getText();

//System.out.println(“driver=” + driver);
System.out.println(title1);

String price1 = driver.findElement(By.xpath(“//*[@id=’priceblock_ourprice’]”)).getText();

System.out.println(price1);

WebDriverWait w1=new WebDriverWait(driver,10);
w1.until(ExpectedConditions.elementToBeClickable(By.xpath(“//[@id=’-to--’]”)));
driver.findElement(By.xpath(“//
[@id=’add-to-cart-button’]”)).click();

}

}



Source link https://sqa.stackexchange.com/questions/35184/-anyone-help-me-out-with-this-as--not-able-to-click-add-to-cart-button

LEAVE A REPLY

Please enter your comment!
Please enter your name here