Hello - i try to run a python-script on pythonanywhere which is using headless-mode -
It tried it with the following code:
os.environ['WDM_LOG'] = '0'
options = Options()
options.add_argument('--headless=new')
options.add_argument("start-maximized")
options.add_experimental_option("prefs", {"profile.default_content_setting_values.notifications": 1})
options.add_experimental_option("excludeSwitches", ["enable-automation"])
options.add_experimental_option('excludeSwitches', ['enable-logging'])
options.add_experimental_option('useAutomationExtension', False)
options.add_argument('--disable-blink-features=AutomationControlled')
srv=Service()
driver = webdriver.Chrome (service=srv, options=options)
But i geht the following error:
Checking for new adds at 2023-09-10 13:26:16.460418
Traceback (most recent call last):
File "/home/Rapid1898/collGumtree.py", line 78, in <module>
driver = webdriver.Chrome (service=srv, options=options)
File "/home/Rapid1898/sel/lib/python3.10/site-packages/selenium/webdriver/chrome/webdriver.py", line 70, in __init__
super(WebDriver, self).__init__(DesiredCapabilities.CHROME['browserName'], "goog",
File "/home/Rapid1898/sel/lib/python3.10/site-packages/selenium/webdriver/chromium/webdriver.py", line 93, in __init__
RemoteWebDriver.__init__(
File "/home/Rapid1898/sel/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 269, in __init__
self.start_session(capabilities, browser_profile)
File "/home/Rapid1898/sel/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 360, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "/home/Rapid1898/sel/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 425, in execute
self.error_handler.check_response(response)
File "/home/Rapid1898/sel/lib/python3.10/site-packages/selenium/webdriver/remote/errorhandler.py", line 247, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally.
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location /usr/bin/chromium is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
Stacktrace:
How is it possible to run a selenium script on pythonanywhere?