Selenium2+python Automation 74-jquery Positioning "reprint"

Source: Internet
Author: User
Tags tag name

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"

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.