R
R
r1dddy4sv2021-03-05 19:01:28
Python
r1dddy4sv, 2021-03-05 19:01:28

Selenium Error while loading page?

My code is uploaded to the pythonanywhere service

from selenium.webdriver.chrome.options import Options
from selenium import webdriver
def start():
    chrome_options = Options()
    chrome_options.add_argument("--headless")
    chrome_options.add_argument("--disable-gpu")
    chrome_options.add_argument('srtart_maximized')
    driver=webdriver.Chrome(options=chrome_options)
    URL='***'
    driver.get(URL)
    #some code
    driver.quit()
    while True:
        try:
            start()
            print('stop')
        except Exception as x:
            print(repr(x))
            print('stop')
        time.sleep(60)


After some time running the code, I get an error:
WebDriverException('invalid session id\n  (Driver info: chromedriver=2.42.591071 (0b695ff80972cc1a65a5cd643186d2ae582cd4ac),platform=Linux 5.4.0-1029-aws x86_64)',
 None, None)


If I run the code from PC everything is fine, but with pythonanywhere I get this error

Answer the question

In order to leave comments, you need to log in

3 answer(s)
E
Evgeniy _, 2021-03-05
@r1dddy4sv

Try adding
' no-sandbox ' and 'disable-dev-shm-usage '

A
agent_2203, 2021-03-05
@agent_2203

Try the following
1. Check the version of chrome-driver, chromium, chromedriver; they must match
2. Run chromedriver in the console and see the output

S
soremix, 2021-03-05
@SoreMix

https://help.pythonanywhere.com/pages/selenium/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question