Hi
I checked about this error
⇨ Usually this error occurs when driver and chrome version are different
my case, both are the same version but still get this error
I tried to change options but does not work
does anyone see my problem??
~~~~~~~~~~~~~~~~~~~~~~~~
environment
~~~~~~~~~~~~~~~~~~~~~~~~
EC2
python 3.11
selenium 4.26.1
webdriver_manager NOT installed
chrome for linux
https://googlechromelabs.github.io/chrome-for-testing/https://storage.googleapis.com/chrome-for-testing-public/130.0.6723.116/linux64/chrome-linux64.zip~~~~~~~~~~~~~~~~~~~~~~~~
I have done
~~~~~~~~~~~~~~~~~~~~~~~~
this works locally
but does not work on EC2
first I installed Google Chrome in EC2
but there was a problem
⇨ google-chrome --version
⇨ symbol lookup error
⇨ aws support says
amazon linux 2 CUPS pakage version is 1.6.3-51
the latest chrome is 1.7
chrome does not work on EC2 ・・he said
I could not understand ・・・( ̄Д ̄;)
that is why
I downloaded Chrome manually then uploaded to EC2
⇨ check below script
I did not set google driver because current selenium can handle right?
after running the script
I checke below path
⇨/home/ec2-user/.cache/selenium/***
i see both versions are the same
why this error still shows??
~~~~~~~~~~~~~~~~~~~~~~~~
error
~~~~~~~~~~~~~~~~~~~~~~~~
Traceback (most recent call last):
File "/home/ec2-user/batch_files/scraping/selenium_test.py", line 145, in <module>
main()
File "/home/ec2-user/batch_files/scraping/selenium_test.py", line 92, in main
driver = webdriver.Chrome(options=options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ec2-user/.pyenv/versions/3.11.5/lib/python3.11/site-packages/selenium/webdriver/chrome/webdriver.py", line 45, in __init__
super().__init__(
File "/home/ec2-user/.pyenv/versions/3.11.5/lib/python3.11/site-packages/selenium/webdriver/chromium/webdriver.py", line 66, in __init__
super().__init__(command_executor=executor, options=options)
File "/home/ec2-user/.pyenv/versions/3.11.5/lib/python3.11/site-packages/selenium/webdriver/remote/webdriver.py", line 212, in __init__
self.start_session(capabilities)
File "/home/ec2-user/.pyenv/versions/3.11.5/lib/python3.11/site-packages/selenium/webdriver/remote/webdriver.py", line 299, in start_session
response = self.execute(Command.NEW_SESSION, caps)["value"]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ec2-user/.pyenv/versions/3.11.5/lib/python3.11/site-packages/selenium/webdriver/remote/webdriver.py", line 354, in execute
self.error_handler.check_response(response)
File "/home/ec2-user/.pyenv/versions/3.11.5/lib/python3.11/site-packages/selenium/webdriver/remote/errorhandler.py", line 229, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.SessionNotCreatedException: Message: session not created: Chrome failed to start: exited normally.
(session not created: DevToolsActivePort file doesn't exist)
(The process started from chrome location /home/ec2-user/.cache/selenium/chrome/linux64/130.0.6723.116/chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
~~~~~~~~~~~~~~~~~~~~~~~~
script
~~~~~~~~~~~~~~~~~~~~~~~~
import time
# import os
# from fake_useragent import UserAgent
from selenium import webdriver
# from selenium.webdriver.chrome.service import Service
# from webdriver_manager.chrome import ChromeDriverManager
#-----------------------------------------------------------------
# selenium
#-----------------------------------------------------------------
def main():
# userdata_dir = 'UserData'
# os.makedirs(userdata_dir, exist_ok=True)
#-------------------------------------------------------------
# options
#-------------------------------------------------------------
# service = Service()
# service.creation_flags = 0x08000000
options = webdriver.ChromeOptions()
options.add_argument('--headless=new')
options.add_argument('--no-sandbox')
options.add_argument('--single-process')
options.add_argument('--disable-dev-shm-usage')
# assert options.capabilities['browserName'] == 'chrome'
# options.browser_version = 'stable'
# assert options.capabilities['browserVersion'] == 'stable'
# options.add_argument('--user-data-dir=/home/ec2-user/' + userdata_dir)
# options.add_argument('--profile-directory=Default')
# options.add_argument('--headless')
# options.add_argument('--disable-application-cache')
# options.add_argument("--remote-debugging-pipe")
# options.add_argument("--user-agent=" + UserAgent(os="windows").chrome)
# options.add_argument("--window-size=1600,1000")
# local
# options.binary_location = '/Users/RU0492/Desktop/works/python/130_0_6723_116/chrome-mac-x64/google_chrome.app'
# EC2
options.binary_location = '/home/ec2-user/z_keys/chrome-linux64/130_0_6723_116/chrome'
# options.binary_location = '/usr/bin/google-chrome'
# options.binary_location = '/usr/bin/google-chrome-stable'
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 【not use】
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# service = Service(
# executable_path=r'/home/ec2-user/z_keys/chromedriver-linux64/130_0_6723_116/chromedriver'
# # executable_path=r'/home/ec2-user/z_keys/chromedriver-linux64/130_0_6723_116/chromedriver.exe'
# )
# service = Service('/home/ec2-user/z_keys/chromedriver-linux64/130_0_6723_116/chromedriver')
#-------------------------------------------------------------
# session start
#-------------------------------------------------------------
# driver = webdriver.Chrome()
driver = webdriver.Chrome(options=options)
# driver = webdriver.Chrome(service=service, options=options)
#-------------------------------------------------------------
# action
#-------------------------------------------------------------
url = "https://dev.classmethod.jp/"
driver.get(url)
time.sleep(3)
title = driver.title
print(f"{title=}")
driver.quit()
#------------------------------------------------------------------
#
#------------------------------------------------------------------
if __name__ == "__main__":
main()