When loading "; i want to decline all the cookies by clicking the button "Decline All". The button is easy to identify and to avoid to click it while it might not be ready or in a non complete state, i use the explicit waiting mecanism of Selenium. Nevertheless i'm getting an 'ElementClickInterceptedException' both with Chrome and Firefox drivers.
Here my source code:
public static void main(String[] args) throws InterruptedException {
ChromeOptions options = new ChromeOptions();
options.addArguments("--start-maximized");
options.addArguments("--incognito");
options.setImplicitWaitTimeout(Duration.ofSeconds(5L));
WebDriver driver = new ChromeDriver(options);
driver.get(";);
WebDriverWait waitManager = new WebDriverWait(driver, Duration.ofSeconds(5L));
WebElement btnDecline = waitManager.until(ExpectedConditions.elementToBeClickable(By.xpath("//button[@id='gdpr-banner-decline']")));
System.out.println(btnDecline.getText());
// Thread.sleep(Duration.ofSeconds(3L));
btnDecline.click();
The console prints as expected "Decline All" but the following click() statement throws the Exception.
I tried to check this behaviour in another browser (Firefox) but still i got the same Exception, the button is not clickable. However when i inserted before clicking a sleep statement, it works fine and no Exception is thrown. I'm looking for a genuine solution of this issue.