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)