python script with selenium on was ec2 instance not finding elements

411 views Asked by At

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!

1

There are 1 answers

0
zacha On

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