Webdriver how to launch different browsers (Python)

Source: Internet
Author: User

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)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.