I create this code with selenium to click the cookie button, because I have to accept cookies to access web site data
from selenium import webdriver
from selenium.webdriver.common.by import By
chromeOptions = webdriver.ChromeOptions()
chromeOptions.add_argument("ignore-certificate-errors")
chromeOptions.add_argument('--headless=chrome')
wbe = webdriver.Chrome(options=chromeOptions)
wbe.get('https://www.asianbetsoccer.com/it/nextgame.html')
wbe.implicitly_wait(10)
wbe.find_element(By.XPATH, "/html/body/button").click()
but it gives me an error because it doesn’t find the button:
wbe.find_element(By.XPATH, "/html/body/button")
File "C:UsersAdministratorAppDataLocalProgramsPythonPython312Libsite-packagesseleniumwebdriverremotewebdriver.py", line 741, in find_element
return self.execute(Command.FIND_ELEMENT, {"using": by, "value": value})["value"]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:UsersAdministratorAppDataLocalProgramsPythonPython312Libsite-packagesseleniumwebdriverremotewebdriver.py", line 347, in execute
self.error_handler.check_response(response)
File "C:UsersAdministratorAppDataLocalProgramsPythonPython312Libsite-packagesseleniumwebdriverremoteerrorhandler.py", line 229, in check_resp
onse
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"/html/body/button"}
(Session info: chrome-headless-shell=124.0.6367.91); For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troub
leshooting/errors#no-such-element-exception
Stacktrace:
GetHandleVerifier [0x00007FF754EB1502+60802]
(No symbol) [0x00007FF754E2AC02]
(No symbol) [0x00007FF754CE7CE4]
(No symbol) [0x00007FF754D36D4D]
(No symbol) [0x00007FF754D36E1C]
(No symbol) [0x00007FF754D7CE37]
(No symbol) [0x00007FF754D5ABBF]
(No symbol) [0x00007FF754D7A224]
(No symbol) [0x00007FF754D5A923]
(No symbol) [0x00007FF754D28FEC]
(No symbol) [0x00007FF754D29C21]
GetHandleVerifier [0x00007FF7551B411D+3217821]
GetHandleVerifier [0x00007FF7551F60B7+3488055]
GetHandleVerifier [0x00007FF7551EF03F+3459263]
GetHandleVerifier [0x00007FF754F6B846+823494]
(No symbol) [0x00007FF754E35F9F]
(No symbol) [0x00007FF754E30EC4]
(No symbol) [0x00007FF754E31052]
(No symbol) [0x00007FF754E218A4]
BaseThreadInitThunk [0x00007FFCEC3E7AC4+20]
RtlUserThreadStart [0x00007FFCEDC2A4E1+33]
can I use selenium or do I have to use another method?