Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Selenium IDE DOM element selection locator

Shulou Source: shulou.com Published: 2022-06-03 05:32:59 09月30日 Update

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.

Tags: Element node positioning object page resource locator size sister text expression video test selection code representative prefix only can pass name Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft Huawei OPPO Reno macOS Shulou Technology