To locate a group of elements, click the first button in a group

Source: Internet
Author: User
def xunhuan2 (self):
Lie = Self.driver.find_elements_by_css_selector (' li.fp14 ')
Liebiao = Len (Lie)
For lie in Range (Liebiao):
Self.driver.find_elements_by_css_selector (' li.fp14 ') [Lie].click ()
Sleep (3)
Self.driver.back ()
Sleep (3)


1. Define the Loop function
2, define variables, using the method of positioning a set of elements CSS
3, define the method, count the number of elements of a group
4. Through the For loop, click
5, using the way to locate the array to click, each time a list of the number of the location of the [lie]

Principle: If a page uses a for loop without using the subscript method, each time the interface element changes,
The purpose of this is to put a set of elements into memory, in the loop, in turn, read the memory of the Lie location method

To locate a group of elements, click the first button in a group

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.