"The insect teacher Speaks Selenium+python" third: Operation Test object

Source: Internet
Author: User
Tags sublime text

First of all, choose an editor, we choose Sublime Text here

>ctrl+b as a shortcut to run the current script

Ii. Writing code

1 #Coding==utf-82  fromSeleniumImportWebdriver3  fromTimeImportSleep4 5Driver=Webdriver. Chrome ()6Driver.get ("http://www.baidu.com")7 #driver.get ("http://m.mail.10086.cn")8 9 Print("Browser Maximization")TenDriver.maximize_window ()#maximize the browser display One " " A #参数数字为像素点, when testing a phone screen, it is necessary to set the size of the browser to the size of the phone screen - print ("Set browser width 480, height 800 display") - driver.set_window_size (480,800) #400代表宽度, 800 stands for height the " " -Driver.find_element_by_link_text (U"News"). Click () -  -Sleep (2) + #Visit the News page -First_url="http://news.baidu.com" + Print("Back to %s"%(First_url)) A Driver.back () atSleep (2) -  - #forward to News page -Second_url="http://news.baidu.com" - Print("forward to%s"%(Second_url)) - Driver.forward () inSleep (2)

"The insect teacher Speaks Selenium+python" third: Operation Test object

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.