Testing ASP.NET sites using master pages with Selenium

What is a good approach to prevent Selenium tests from breaking when working with the changing attributes "Name" and "Id" of the control that is displayed on the ASP.NET page using the main page? I want to avoid changing my tests when ASP.NET displays web page controls with different DOM identifiers.

+3
source share
2 answers

http://www.stevetrefethen.com/blog/AutomatedTestingOfASPNETWebApplicationsUsingSelenium.aspx

Selenium solves this problem by using XPATH and providing the ability to search for controls based on XPATH expressions, facilitating the need for hard HTML tag code in a test script. For example, ASP.NET runtime can visualize identifier attributes that look like this:

id="ctl00_cphContents_gridMaint_DataGrid"

Finding this control using an XPATH expression can be simplified to something like this:

table[contains(@id, "gridMaint")]

In case the nesting DataGrid changes the script continue to function properly for how long since the table identifier contains the text "GridMaint".

+5
source

- CSS. , XPath. , div .myDiv "css =.myDiv". , - , XPath "//div [@ class= 'myDiv']" "//div [contains (@class, 'myDiv']" , CSS , XPath .

+3

Source: https://habr.com/ru/post/1718490/


All Articles