0 votes
1 view
in Devops and Agile by (17.7k points)

We use Selenium to test the UI layer of our ASP.NET application. Many of the test cases test longer flows that span several pages.

I've found that the tests are very brittle, broken not just by code changes that actually change the pages but also by innocuous refactorings such as renaming a control (since I need to pass the control's clientID to Selenium's Click method, etc) or replacing a grid view with a repeater. As a result, I find myself "wasting" time updating string values in my test cases in order to fix broken tests.

Is there a way to write more maintainable Selenium tests? Or a better web UI testing tool?

Edited to add: Generally the first draft is created by recording a test in the IDE. (This first step may be performed by QA staff.) Then I refactor the generated C# code (extract constants, extract methods for repeated code, maybe repeat the test case with different data, etc). But the general flow of code for each test case remains reasonably close to the originally generated code.

1 Answer

0 votes
by (48.1k points)

You can run your selenium tests, by recording them or playing them back.

What you can do is to build an object model around pages in order that you can call a method like "clickSubmit()" instead of clicking on an id (with a naming convention for these ids), that permits selenium tests to survive several changes and run successfully.

...