Python+selenium-webdriver Introduction (i)

Source: Internet
Author: User

First, the browser to maximize

Second, set the browser resolution size

Third, print the page title

Four, print the URL

V. Control browser forward or backward

#!/usr/bin/env python
#-*-Coding:utf-8-*-

From selenium import Webdriver
Import time

Browser = Webdriver. Firefox ()

#浏览器最大化

Browser.maximize_window ()

#设置浏览器分辨率大小
Browser.set_window_size (800,600)


#访问百度首页
Index_url = "Http://www.baidu.com"
Print browser.title# Printing page title
Print "Now access%s"%index_url
Browser.get (Index_url)
Time.sleep (2)

# Visit Baidu News Page
News_url = "Http://news.baidu.com"
Print "Now access%s"%news_url
Browser.get (News_url)
Time.sleep (2)

# back or back to Baidu homepage
Print "Back to%s"%index_url
Browser.back ()
Time.sleep (2)

#前进到百度新闻页面
Print "forward to%s"%news_url
Browser.forward ()
Time.sleep (2)

Browser.quit ()

Today's knowledge points, most of them from the Insect master blog, need to know more about the text can be viewed;

Original link: http://www.cnblogs.com/fnng/p/3171383.html

Python+selenium-webdriver Introduction (i)

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.