Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Introduction to the method of selenium element location

2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

Element positioning method

Element name

Webdriver API

Id

Find_element_by_id ()

Name

Find_element_by_name ()

Class name

Find_element_by_class_name ()

Tag name

Find_element_by_tag_name ()

Link text

Find_element_by_link_text ()

Partial link text

Find_element_by_partial_link_text ()

Xpath

Find_element_by_xpath ()

Css selector

Find_element_by_css_selector ()

The operation method of the element

Method

Description

Clear

Clear element content

Send_keys

Analog key input

Click

Click

Submit

Submit the form

Introduction to Xpath positioning

Expression.

Result

/ xxx

Select the root node xxx

/ xxx/yyy

Select elements based on absolute path

/ / xxx

Scan the entire document to find all xxx elements

/ / xxx/yyy

All yyy elements whose parent element is xxx

.

Select the parent element node of the current node

..

Select the parent element address

/ / xxx [@ id]

Select all elements that have id attributes in xxx elements

/ / xxx [@ id=yyy]

Select all xxx elements whose id attribute is yyy

/ / * [count (xxx) = 2]

Count the nodes with the number of xxx elements = 2

/ / * [local-name () = 'xxx']

Find the element whose tag is xxx

/ / * [starts-with (local-name (),'x')]

Find all tag elements that begin with x

/ / * [contains (local-name (),'x')]

Find all tag elements that contain x

/ / * [string-length (local-name ()) = 3]

Find all elements with tag length 3

/ / xxx | / / yyy

Multiple path lookup

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report