Selenium python bindings preliminary usage and simple reference examples

Source: Internet
Author: User
Tags selenium python

The simplest way to master selenium is to learn by example, and the test examples and analysis of previous projects are given below.
#-*-Coding:utf-8-*-import timefrom Selenium import webdriver# use the Firefox browser to show the effect, creating an instance of Selenium webdriver Driver = webdr Iver. Firefox () #driver. Get method to open test URL 127.0.0.1:8000/chasingsomeonedriver.get (' http://127.0.0.1:8000/ChasingSomeone/') # Maximized screen (except for display with negligible) Driver.maximize_window () Sleep units are calculated in seconds, without adding unit Time.sleep (1) # Find the page element and enter the user name and password, specific find_element_by_* The method will summarize the # Send_keys function to the corresponding page element in the anchor element signin_email = driver.find_element_by_name (' username ') Signin_email.send_keys (" [email protected] ") Signin_password = driver.find_element_by_name (' password ') Signin_password.send_keys (" 123 ") Time.sleep (2) # Find the login buttom and click submit Signin_submit_button = driver.find_element_by_name (' login ') signin_submit_ Button.Click () Time.sleep (2) # Exit Driver.close ()

This is one of the simplest examples of Python selenium, and the added functionality will be based on a simple example of this extension
Then give an example of the official website, you can analyze, analysis can be confirmed by the last officer net, attached link
From selenium import webdriverfrom selenium.webdriver.common.keys import keysdriver = Webdriver. Firefox () driver.get ("http://www.python.org") assert "Python" in Driver.titleelem = Driver.find_element_by_name ("q") Elem.clear () Elem.send_keys ("Pycon") Elem.send_keys (Keys.return) assert "No results found." Not in Driver.page_ Sourcedriver.close ()
Content Reference http://selenium-python.readthedocs.io/installation.html

Selenium python bindings preliminary usage and simple reference examples

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.