0

I'm trying to integrate Selenium into our test suite for one of our projects. I've been using the Katalon Studio and plug in for Firefox. It all works well in these tools - However when I export the test code into .net the test runs too quickly and soon falls over (we have a lot of ajax loading so the form takes time to appear/the element is invisible).

We would rather that the test took longer to execute than have to put in a lot of time so we want to make the driver delay between each action by 2 seconds (this is a setting available in Katelon Studio), we haven't been able to work out how to set this without adding thread.sleeps all over the place.

Has anyone done this before?

Thanks.

  • Add explicit waits. Plenty of topics on the subject. – FDM Jan 5 '18 at 12:34
  • @FDM is that the be all and end all? Manually adding in waits is something we want to avoid. – Dave Jan 5 '18 at 14:12
  • You need to either add explicit waits, or wait for expected condition. Selenium allows this (many different conditions), if your Katalon Studio does not, you choose a poor tool for the job. That's why we wrote our own wrapper over Selenium: we have all the power of Selenium, suited for OUR needs. Also, Selenium is free. – Peter M. - stands for Monica Jan 5 '18 at 15:13
1

If you want reliable tests, you're going to have to write at least some of the code by hand. Test cases generated by the Firefox plugin are simply too fickle to be of much use. However, they can provide a decent starting point so that you don't have to write all of the code from scratch.

As an example, you say you want to add a static delay of 2 seconds between each action. What happens if the ajax on the page takes 2001 ms? Does that mean the test should fail? What if there is some latency issue between the machine running the test and the web server and one action takes a bit longer than usual? How much time will be spent verifying whether each failed test was truly a failure, and, if it wasn't, re-running the test to assure that the next pass is successful?

Just like any other software project, an automated test suite accumulates technical debt. Trying to build a Selenium test suite solely from tests generated by the Firefox plugin (or any other test generation tool) will result in the following negative consequences:

  1. Unreliable/flaky tests, as described above
  2. Tests that break if even the slightest changes are made to the HTML of the application under test
  3. Higher cost of test maintenance

There may be others as well, depending on your organization.

The primary benefit of using a test generation tool:

  1. A set of basic test cases can be created quickly and easily, so some benefit can be observed early in the process without much overhead

The question each team must ask is whether the pros outweigh the cons. In the short term, it may be beneficial to use the Firefox plugin to generate your tests, but if your team is already encountering problems of the nature you describe, it could spell trouble down the road.

If nobody on your team has enough programming knowledge to write test cases from scratch, it may be a good idea to request personnel who can help.

  • Thanks VanderLinden - We've taken this on board and gone down the route of using the tool to generate the tests and then customise them in c#. No shortcuts to good testing eh? – Dave Jan 8 '18 at 11:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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