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.
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".
- CSS. , XPath. , div .myDiv "css =.myDiv". , - , XPath "//div [@ class= 'myDiv']" "//div [contains (@class, 'myDiv']" , CSS , XPath .
Source: https://habr.com/ru/post/1718490/More articles:Visual Studio по умолчанию Открыть файл Действие - c#How is the "White Label" for my ASP.Net MVC application? - asp.net-mvcReference jQuery correctly in ASP.NET MVC - jqueryhttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1718488/why-does-nhibernate-need-non-settable-members-to-be-virtual&usg=ALkJrhh6BfCQ-d-oOaH4b-mHD8cxsPyBNwWebRequest Multithreading Calls and Assertions - multithreadingSaving Ruby on Rails Session Header - caching.Net System.OutOfMemoryException populates data - .netjQuery take url with variables from a link and send it via Ajax - jquerybranching optimization by reordering - c ++SQL Pivot MIN (COUNT (- sql-serverAll Articles