Cannot find element with any selector not even with XPATH (python).

79 views
Skip to first unread message

Mr. GameSucht

unread,
Sep 15, 2023, 12:08:25 PM9/15/23
to Selenium Users
This is the code (python) in which i go to the website "https://aniworld.to/anime/stream/hunter-x-hunter/staffel-2/episode-56" and try to get the fullscreen button in the image below:
fullscreen.pngfrom webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.service import Service
from selenium import webdriver
import time

chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("--start-maximized")
chrome_options.add_extension('D:\Chrome_Bot\extension_5_6_0_0.crx')
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=chrome_options)
driver.get("https://aniworld.to/anime/stream/hunter-x-hunter/staffel-2/episode-56")

input("Press Enter to continue...")

fullscreen_button = driver.find_element(By.XPATH, "/html/body/div[2]/div/div[1]/button[4]")
print(fullscreen_button)

And I get this error message when searching by XPATH:
Traceback (most recent call last):
  File "D:\AnimeBot\chrome_extension\debug_chrome.py", line 15, in <module>
    fullscreen_button = driver.find_element(By.XPATH, "/html/body/div[2]/div/div[1]/button[4]")
  File "C:\Users\simon\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\selenium\webdriver\remote\webdriver.py", line 739, in find_element
    return self.execute(Command.FIND_ELEMENT, {"using": by, "value": value})["value"]
  File "C:\Users\simon\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\selenium\webdriver\remote\webdriver.py", line 345, in execute
    self.error_handler.check_response(response)
  File "C:\Users\simon\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\selenium\webdriver\remote\errorhandler.py", line 229, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"/html/body/div[2]/div/div[1]/button[4]"}
  (Session info: chrome=116.0.5845.188); For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#no-such-element-exception
Stacktrace:
GetHandleVerifier [0x002937C3+48947]
(No symbol) [0x00228551]
(No symbol) [0x0012C92D]
(No symbol) [0x00159E38]
(No symbol) [0x00159EFB]
(No symbol) [0x00188EF2]
(No symbol) [0x001750D4]
(No symbol) [0x001875DA]
(No symbol) [0x00174E86]
(No symbol) [0x001516C7]
(No symbol) [0x0015284D]
GetHandleVerifier [0x004DFDF9+2458985]
GetHandleVerifier [0x0052744F+2751423]
GetHandleVerifier [0x00521361+2726609]
GetHandleVerifier [0x00310680+560624]
(No symbol) [0x0023238C]
(No symbol) [0x0022E268]
(No symbol) [0x0022E392]
(No symbol) [0x002210B7]
BaseThreadInitThunk [0x76066BD9+25]
RtlGetFullPathName_UEx [0x76EF8FD2+1218]
RtlGetFullPathName_UEx [0x76EF8F9D+1165]
(No symbol) [0x00000000]
Reply all
Reply to author
Forward
0 new messages