joker20
joker20

Reputation: 73

How to click cookies pop up window with python selenium

I am trying to click 'akceptuj wszystkie' button in facebook: screenshot of window

I tried to click it by actions but there is error unable to locate alement:

selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":"._42ft _4jy0 _9o-t _4jy3 _4jy1 selected _51sy"}

I tried by switch to window but there is error: driver.switch_to_window(driver.window_handles[1]) IndexError: list index out of range

how can I click this button, any ideas?

Upvotes: 0

Views: 162

Answers (1)

sayhan
sayhan

Reputation: 1184

Seems like that pop-up is not an iframe or window. Please try below code.

driver.find_element_by_css_selector("div._4t2a button[data-cookiebanner='accept_button']").click()

edit : quotes fixed

Upvotes: 1

Related Questions