How can adjust test scripts in selenium when user interface changes constantly?

1.6k views Asked by At

We recently ran in to a problem.Our team has automated test scripts with selenium. Now we got change request in User Interface, So we have modified the css.

The issue is automated test scripts are not working. we know this is due to css change.

My question is :

What is the best approach to handle those scenarios effectively?

2

There are 2 answers

1
faramka On BEST ANSWER

It is the biggest inconvenience of testing... When something is changed, you have to rewrite your test script.

You can choose the best way of elements localisation for you. But there is always risk that xPath (and CSS or locators of any other type) will be changed. In fact, you can't write script for all possibilities. You just have to change manually your script when there are any changes in app.

This is a fact which you are not able to avoid.

0
frennky On

There are ways to to reduce this inconvenience. One very popular solution is to use Page Object pattern.

The idea is to decouple test logic from application under test by inserting one layer in between. That way if application changes you don't need to change test logic, you just need to update affected Page Objects.

To simplify this update process, it is also a good practice to use a tool (or create your own) that can generate Page Object classes.