简体   繁体   中英

Calling Python script with Selenium Webdriver from PC on a server

I have a Python script that uses Selenium Webdriver. I want to run this on a server remotely. When running my script directly on the server through command window, everything works fine. But when I'm trying to trigger this remotely through a program on my local PC to the server, it doesn't work. It seems to stop at driver = webdriver.Chrome(webdriverlink) . It doesn't fail, it just won't continue. So it seems like it doesn't actually opens a browser.

Isn't this possible when you're not logged in on the server and not running it directly from there?

I've saved my script in a py-file, and is triggering it in both ways throuh the command line python <myFileName>.py

I found a solution from another forum after a lot of searching. So for all of you struggling with the same problem, this worked for me:

I've added the following code:
options = webdriver.ChromeOptions()
options.add_experimental_option('excludeSwitches', ['enable-logging'])

and changed from: driver = webdriver.Chrome(webdriverlink)
to driver = webdriver.Chrome(executable_path=webdriverlink,options=options)

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