Webdriver supports Firefox (firefoxdriver),IE (internetexplorerdriver), Opera (operadriver) and Chrome (chromedriver) because of the domestic ban http://code.google.com and http://www.seleniumhq.org/download/ the software download, you can go to csdn download, there are many children's shoes to share the software.
First, Firefox:
No download required Firefoxdriver, write code directly to
From selenium import Webdriver
Browser = Webdriver. Firefox ()
Browser.get (' https://www.baidu.com/')
Second, IE:
1, download IEDriverServer.exe ( machine installed IE browser )
2 . Place the IEDriverServer.exe in the python installation directory C:\Python27( When the Python environment is installed , C:\Python27 has been added to the system environment variable under Path . or put it in the IE installation directory, and add the directory to the system environment variable Path below;
How to do this without adding an environment variable can also be written in the code:
From selenium import Webdriver
Import OS
Iedriver = "C:\Program files\internet Explorer\iedriverserver.exe"
os.environ["Webdriver.chrome.driver"] = Iedriver
Browser = Webdriver. Chrome (Iedriver)
Browser.get (' https://www.baidu.com/')
Three, Chrome:
1, download ChromeDriver.exe
2 put in python installation directory c:\python27 ( python environment, already c:\python27 add to system environment variables path below ) or put it in the installation directory of Chrome path below;
How to add an environment variable, or you can write it in code:
From selenium import Webdriver
Import OS
Chromedriver = "C:\Program Files (x86) \google\chrome\application\chromedriver.exe"
os.environ["Webdriver.chrome.driver"] = Chromedriver
Browser = Webdriver. Chrome (Chromedriver)
Browser.get (' https://www.baidu.com/')
Webdriver how to launch different browsers (Python)