How to handle the Accept All button that appears with the page loading.
Asked
Active
Viewed 350 times
1
![](../../users/profiles/7429447.webp)
DebanjanB
- 118,661
- 30
- 168
- 217
-
That would be great you either share the URL or DOM structure. – UnknownBeast Jun 29 '20 at 06:28
2 Answers
1
To click on Accept All button you have to induce WebDriverWait for the element_to_be_clickable()
and you can use either of the following Locator Strategies:
Using java and
XPATH
:new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//button[@class='optanon-allow-all accept-cookies-button']"))).click();
Using python and
CSS_SELECTOR
:WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "button.optanon-allow-all.accept-cookies-button"))).click()
Note : For python clients you have to add the following imports :
from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.common.by import By from selenium.webdriver.support import expected_conditions as EC
![](../../users/profiles/7429447.webp)
DebanjanB
- 118,661
- 30
- 168
- 217
-
@Md.Mahfuz-Ul-AlamBadhan Great News !!! Please [_accept_](https://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work) the _Answer_ by clicking on the hollow tick mark beside the _Answer_ which have solved your query and _Upvote_ the _Answers_ which were helpful to you for the benefit of the future readers. – DebanjanB Jun 30 '20 at 08:24
0
You can simply click "Accept All" button after page is loading.
![](../../users/profiles/6059967.webp)
Justin Lambert
- 839
- 1
- 7
- 11
-
-
-
use this xpath to click "accept all" button //button[@title='Accept All'] – Justin Lambert Jun 29 '20 at 07:46