Go to Blog: Shanghai-leisurely
Objective
Element positioning can be said to be the learning automation of the small partner encountered a threshold, learned to locate also opened the two veins, before sharing selenium 18-like martial arts, plus five JS positioning Dafa.
This is not enough, today to share a positioning artifact jquery, it is the inverse of the sky!
First, jquery search elements
1. Press F12 to enter the console
2. Click the All button
3. If the input box does not appear on the right, click the small arrow button
4. Input box input jquery positioning syntax, such as: $ ("#input1")
5. Click the Run button
6. The positioned element appears on the left, and if more than one is shown in the list
Second, jquery localization grammar
1.jquery syntax You can learn W3school tutorial: http://www.w3school.com.cn/jquery/jquery_syntax.asp
2. The format is as follows:
$ (selector). Action ()
--selector: The positioning syntax here is consistent with the CSS's positioning syntax, such as: ID is #,class is dot (.), tag tag name is not signed in front of
--action: This is an action behavior event after locating an element, such as the Click
Third, jquery behavior
1. Send text syntax: $ (selector). val (the value of the input text)
2. Empty text syntax: $ (selector). Val (") # empty string, two single quotes
3. Click the button: $ (selector). Click ()
Iv. Reference Scripts
# Coding:utf-8
From selenium import Webdriver
Import time
Driver = Webdriver. Firefox ()
Driver.get ("Https://passport.cnblogs.com/user/signin")
Driver.implicitly_wait (20)
# Enter your account
Username = "$ (' #input1 '). Val (' Shanghai-Yo ')"
Driver.execute_script (username)
# Clear Text
# Time.sleep (5)
# clear = "$ (' #input1 '). Val (')"
# Driver.execute_script (Clear)
# Enter password
PSW = "$ (' #input2 '). Val (' Yoyo ')"
Driver.execute_script (PSW)
# Click the login button
Button = "$ (' #signin ')." Click () "
Driver.execute_script (Button)
Selenium2+python Automation 74-jquery Positioning "reprint"