3

How can we maintain Selenium scripts when the application changes?

Specifically, how do we define and manage automation to keep it up to date with changes in the application being tested?

5
  • Could be retitled "How to write robust selenium scripts for a changing product" but I don't have edit priv's to suggest. body could be improved also. Commented Dec 29, 2015 at 11:19
  • 1
    How would you define "different changes"- like change in functionality, changes in UI or anything else? Commented Dec 29, 2015 at 11:31
  • Maybe "How to write robust selenium scripts for a ui that changes?" ? Commented Dec 29, 2015 at 12:08
  • 3
    Edited the question to make the intent clearer.
    – Kate Paulk
    Commented Dec 29, 2015 at 12:21
  • Do you use the page object model?
    – Robben
    Commented Dec 29, 2015 at 16:54

6 Answers 6

6

To make your selenium scripts work well with a changing product do the following:

  • Use good css identifers. Use ID when available. Avoid layout tags such as TABLE, H3, etc. Avoid css styling such as .button that doesn't describe the actual item even if unique on the page in question. Look for a balance between over-specifying which is an issue with pages that change over time or are dynamically generated by a web application framework, and under-specifying which raises the issue of not identifying the fragment uniquely enough.
  • Use a page object model. Identify your html fragments in one place and give them meaningful names. Then your tests can actually be readable in an english-like fashion and when a fragment is used in multiple places you will only need to change the definition in one place when that part of the page changes. Put a lot of time and effort and thinking into how you name objects and mature it over time. This is one of the toughest parts of automation (and programming in general!)
  • Break out large tests into more smaller tests. Lots of small tests is generally better than a few large ones. It is generally easier to maintain them, they are easier to read and when they break it can be clearer as to the actual issue. You can also choose to run subsets more easily such as smoke tests, fast tests, slow tests. happy tests, sad tests, etc.
  • Work closely with the developers making the changes. Enable them to run the same selenium tests before they are finished. Work with them on naming objects and naming standards. Share tools with them.
0
1

Do you mean something like version control? Your developers use probably SVN or GIT, so all your tests should be stored there as well. This way you can checkout any old version of the code and the right tests for it will be checked out too.

2
  • 1
    this is an excellent recommendation (I love git!). However it doesn't really relate to the specific question as I understand it. If I include that I would then start adding a lot of other good programming practices. The list is long. Commented Dec 29, 2015 at 12:42
  • +1 I Just wanted so say the same. Many people don't version control such things but it's code like everything else!
    – bish
    Commented Dec 30, 2015 at 6:23
1

As if your question is much unclear to me, from my understandings if you are using selenium web driver then there are a lot of automation frameworks available to maintain the selenium scripts. One of them is Page Object Model.

Problem?


The chief problem with script maintenance is that if 10 different scripts are using the same page element, with any change in that element, you need to change all 10 scripts. This is time consuming and error prone.


A better approach to script maintenance is to create a separate class file which would find web elements, fill them or verify them. This class can be reused in all the scripts using that element. In future if there is change in the web element, we need to make change in just 1 class file and not 10 different scripts.

This approach is called Page Object Model(POM). It helps in making code more readable, maintainable, and reusable.

For more details refer this. Hope it will help you !

1
  • 1
    Sameer, can you please add some description around your answer. A simple one liner or a link is not the perfect way to answer a question. Commented Dec 29, 2015 at 11:30
0

The same question has been asked multiple times :

Building "slow to break" regression tests

How can I structure Selenium tests in a way that minimizes the maintenance work?

I would suggest you to go through both these links because it has loads of ideas and suggestions people have mentioned as to how you can build a properly maintainable test framework. Also I could think of this particular link , which talks about the principle of DRY (Don't Repeat Yourself) to be particularly apt for your scenario. Please go through it as well.

0

I think this is asking, "How do I keep my automation up to date with my app?" There is no easy answer to this. There are three possible outcomes when the app changes:

  • Test suite does not require any changes. The app implementation changed but the interface did not.
  • Test reports false positives. The test reports a bug but the app is fine. If someone investigates every test failure, they will presumably update the test to fix the problem.
  • Test reports false negatives. The test passes but the app has bugs. There is no magical way to find these problems; you need to know the app and the tests well enough to realize that they are out of sync.

By default, especially when ownership of a test suite is handed off to someone else, no one worries about false negatives. Identifying them required reading and understanding the code.

-1

I have also faced similar issue while writing automation for my project. Test maintenance is one of the important issue while creating automation scripts.

I was looking for some free and open source tool which can develop selenium automation without writing any code and which is easy to maintain.

I didn't find anything which I needed so I've created Almond Automation. It is codeless web automation testing tool.

It provides the below features:

  1. Simple ui to create testcase and testsuite.
  2. Execute testcase and view status and screenshot in ui.
  3. Create common testcase and include them in other testcase. If there is any change then you need to change only testcase.

There are other features apart from few mentioned above. Please visit Almond Automation for complete installation and documentation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.