`
WebDriver Driver = null;
WebDriverWait wait = null;
@BeforeTest
public void beforeTest() {
System.setProperty("webdriver.chrome.driver","src\\test\\resources\\drivers\\chromedriver.exe");
ChromeOptions options = new ChromeOptions();
options.setExperimentalOption("excludeSwitches",Arrays.asList("disable-popup-blocking"));
options.addArguments("--disable-popup-blocking");
Driver = new ChromeDriver(options);
Driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
wait = new WebDriverWait(Driver, 25);
}
@Test(dataProvider = "dp")
public void Test( String s) {
String SearchWord = s;
String url = "https://www.firstcry.com/";
Driver.get(url);
wait.until(ExpectedConditions.alertIsPresent());
By popupdeny1 = By.xpath("//*[@id=\"deny\"]");
By searchbox = By.id("search_box");
By sortSelect = By.xpath("/html/body/div[5]/div[2]/div/div[2]/div[1]/div[2]/div[1]/div");
By descendingPrice = By.xpath("/html/body/div[5]/div[2]/div/div[2]/div[1]/div[2]/div[1]/ul/li[4]/a");
if(Driver.findElement(popupdeny1).isDisplayed())
Driver.findElement(popupdeny1).click();`
I am automating firstcry webpage for a study purpose. There are few popups in this url, which i need to handle before searching for a product and sort the items based on price
I even added Chromeoptions in browser setting, but still the popups are coming...here is the code part. I tried to click the deny button in my code, but ended with error saying cant find the element.
Any help is appreciated