0

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?

joker20
  • 53
  • 2
  • 8
  • `driver.switch_to_window` won't work because the cookies popup is not a window. – PApostol Aug 04 '21 at 11:42
  • See this: [handling-accept-cookies-popup-with-selenium-in-python](https://stackoverflow.com/questions/64032271/handling-accept-cookies-popup-with-selenium-in-python). Also see this: https://selenium-python.readthedocs.io/waits.html. – CypherX Aug 04 '21 at 11:46

1 Answers1

1

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

sayhan
  • 1,168
  • 1
  • 16
  • 22