简体   繁体   中英

python script with selenium on was ec2 instance not finding elements

So my code works on my local machine where I am able to scrape and get all the needed data. However, when trying to run it remote on Amazon linux server I have gotten errors like selenium can't find element, selenium.common.exceptions.WebDriverException: Message: chrome not reachable with the options shown below.

I have tried messing around with downloading chrome and selenium in certain locations following many guides saying the same thing.

I'm wondering if it is a compatibility issue. Using Google Chrome 85.0.4183.121 and ChromeDriver 2.37.544315

chrome_options = Options()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--window-size={}x{}'.format(1280, 1024))

chrome_path = '/home/ec2-user/usr/bin/chromedriver'
    #chrome_options.binary_location = '/usr/bin/google-chrome'
driver = webdriver.Chrome(ChromeDriverManager().install(), options=chrome_options)

Any insight would be appreciated, thanks!

I figured it out. I needed to run a remote server in order to connect remotely. Also have to use webdriver.Remote.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM