简体   繁体   中英

python - Speeding up Chrome Webdriver in Selenium

I am making a simple bot with selenium that will like, comment and message people on certain intervals.

I am using chrome web driver:

browser = webdriver.Chrome()

Also, I am on a x64 linux system. Distro is ubuntu 15.04 and am running with python3 from terminal.

and this works good and all, but it's pretty slow. I know as my code progresses, testing the app will become a pain. I've looked into this already and know it may have something to do with the proxy settings. I am clueless when it comes to this type of stuff.

I fiddled with my system settings and changed my proxy settings to not require a connection, but nothing changed.

I notice when the driver loads, I see 'Establishing secure connection' for a few seconds in the browser window. I feel this is a culprit. Also, 'establishing host' shows up multiple times. I'd say it takes about 5-8 seconds just to get a page.

login_url = 'http://www.skout.com/login'
browser.get(login_url)

In what ways can I speed up chrome driver, and is it proxy settings? It could definitely be something else.

Thanks for your time.

Chrome webdriver can be clunky and a bit slow to initialize as it is spawning a fresh instance every time you call the Webdriver object.

If speed is of the utmost importance I might recommend investing some time into looking at a headless alternative such as PhantomJS . This can save a significant amount of time if you are running multiple tests or instances of your application.

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