Quantcast
Channel: Active questions tagged selenium - Stack Overflow
Viewing all articles
Browse latest Browse all 98827

Selenium can't find element on server, but can on local device

$
0
0

I'm trying to write a python script that will go to a website I host, wait for the external java script file to load, and then retrieve some elements that it creates. And it works great on my machine, but when I run it on pythonanywhere, it gives me this error:

Traceback (most recent call last):  File "/home/SmallCoder14/orthodox_saints_of_the_day/get_quotes.py", line 14, in <module>    quote = WebDriverWait(driver, 10).until(  File "/usr/local/lib/python3.10/site-packages/selenium/webdriver/support/wait.py", line 89, in until    raise TimeoutException(message, screen, stacktrace)selenium.common.exceptions.TimeoutException: Message: Stacktrace:#0 0x5f8f634cbe89 <unknown>

My code is:

from selenium import webdriverfrom selenium.webdriver.common.by import Byfrom selenium.webdriver.support.ui import WebDriverWaitfrom selenium.webdriver.support import expected_conditions as ECoptions = webdriver.ChromeOptions()options.add_argument('--no-sandbox')options.add_argument("--headless")driver = webdriver.Chrome(options=options)driver.get("https://SmallCoder14.pythonanywhere.com/quote-of-the-day")quote = WebDriverWait(driver, 10).until(    EC.presence_of_element_located((By.XPATH, "/html/body/div/p[1]")))driver.quit()

I tried using implicitly_wait for 10 seconds instead of WebDriverWait for 10 seconds, but that yielded the same error. I also tried adding the --disable-dev-shm-usage argument, but that also yielded the same error


Viewing all articles
Browse latest Browse all 98827

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>