Accept Facebook Cookie policy by Selenium Web Driver
As the ID and class create dynamically so my best approce the xpath as bellow driver.findElement(By.xpath("//button[@data-cookiebanner='accept_button']")).click();
As the ID and class create dynamically so my best approce the xpath as bellow driver.findElement(By.xpath("//button[@data-cookiebanner='accept_button']")).click();
At first we have to import packages import org.openqa.selenium.support.ui.WebDriverWait; import org.openqa.selenium.support.ui.ExpectedConditions; 2. WebDriverWait wait =new WebDriverWait(driver,Duration.ofSeconds(5)); wait.until(ExpectedConditions.presenceOfElementLocated (By.xpath("/html/body/div[3]/div[2]/div")));