"Selenium2 Python Automation Test" (7)--positioning a group of objects

Source: Internet
Author: User

Locating a group of objects

Locate a group of objects--find_elements_by_ ... (), note, here is elements, plural. The returned result is a list of values that we need to use to get the elements we want. There is so much to be aware of. See a piece of code immediately understand:

This is Baidu in the upper right corner of a few tags. We see that the class from "News" to "academic" is the same:

# coding: utf-8
from selenium import webdriverdriver = webdriver.Firefox()driver.get("http://www.baidu.com")driver.maximize_window()
grou = driver.find_elements_by_class_name("mnav")
# 查看该组对象的长度
print len(grou)
# 点击新闻按钮
driver.find_elements_by_class_name("mnav")[0].click()

The above is to locate a set of elements, and then remove the first element, if you click on "Map" on [2].click (). This is the basic knowledge of Python.

Originally also want to continue to say IFRAME positioning, but think there is still more special, take out alone better, so today said so much.

Public search "automated test Practice" or scan the QR code below to add attention ~ ~ ~

"Selenium2 Python Automation Test" (7)--positioning a group of objects

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.