简体   繁体   中英

Selenium in python - initializing the driver

I have downloaded the necessary drivers for using selenium in chrome. This is the code I am using:

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Chrome('./chromedriver')

When I am initialising the variable driver itself, a chrome page is opened. I do not want that to happen. I want to open a chrome page only when I use the driver.get() method. How do I do it?

The driver will open chrome by default.

If you want to open the chrome by driver.get() method then use the code below:

Try this:

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Chrome('./chromedriver')

driver.get(url='http://www.facebook.com')

Pass the url in driver.get()

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