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

Selenium IDE DOM element selection locator

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

Resource recommendations:

Video resources: series of videos related to software testing

Community Resources: automated Test Communication Group

DOM locator

DOM (Document ObjectModel) represents the entire HTML document and can be accessed by using javascript, through which the javascript result is evaluated as an element in a page. The code example is as follows:

Dom=document.getElementById ('loginForm') (3)

Dom=document.forms ['loginForm'] (3)

Dom=document.forms [0] (3)

Document.forms [0] .username (4)

Document.forms [0] .elements ['username'] (4)

Document.forms [0] .elements [0] (4)

Document.forms [0] .elements [3] (7)

Note: since only dom locators use positioning expressions that start with "document", the prefix "dom=" of positioning expressions can be ignored.

More common ways to find page elements are as follows:

GetElementById () returns a reference to the first object that owns the specified id.

GetElementsByName () returns a collection of objects with the specified name.

GetElementsByTagName () returns a collection of objects with the specified tag signature.

GetElementsByClassName returns a collection of objects with the specified Class.

ChildNodes returns all child nodes (including text nodes)

Children returns all html child elements

FirstChild returns the first child node of the current page element (including the text node)

FirstElementChild returns the first child of the current page element

LastChild / lastElementChild

NextSibling returns the next sister node of the current node

NextElementSibling returns the next sister element node of the current node

PreviousSibling / previousElementSibling

ParentElement / parentNode

QuerySelector supports css selector positioning elements.

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

Internet Technology

Wechat

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

12
Report