[Code] Python+selenium implementation opens a Web page

Source: Internet
Author: User

Reprinted from: http://www.cnblogs.com/fnng/archive/2013/05/29/3106515.html

Enter the following code in eclipse:

#!/usr/bin/env python

From selenium import Webdriver
From selenium.common.exceptions import nosuchelementexception
From Selenium.webdriver.common.keys import keys

#chrome Download url:http://www.xdowns.com/soft/xdowns2009.asp?softid=136971&downid=10&id=138354

#路径要具体到chrome driver exe file

#否则会出现错误: selenium.common.exceptions.WebDriverException:Message: ' Chromedriver executable needs to being available in the Path.

Chrome_driver_path = "C:\Python27\selenium\webdriver\chromedriver\chromedriver"
Driver = Webdriver. Chrome (Chrome_driver_path)
Driver.get ("http://baidu.com")

To execute the code, you can see:

Baidu's Web page opens in Chrome.

[Code] Python+selenium implementation opens a Web page

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.