Selenium Worst Practices

Worst Practices of Automated Testing using Selenium

Worst Practices of Test Automation using Selenium

Selenium automates browsers, that’s it!,

Primarily it is for automating web applications for testing purposes, but is certainly not limited to just that.

Boring web-based administration tasks can (and should) also be automated as well.

Selenium Worst Practices, Automating Captcha fields, Performance Testing, Automated file downloads, automation of Gmail, Facebook logins, and Link spidering.

We have so many best practices for Test Automation using Selenium, and some worst practices also there, according to Selenium official web site (www.selenium.dev), we have seven worst practices of Selenium for Automated Testing.

Worst Practices of Selenium

1) Automating Captchas

Nowadays we can see captchas in most of the public web applications for registering with those applications.

CAPTCHA, short for Completely Automated Public Turing test to tell Computers and Humans Apart, is explicitly designed to prevent automation, so do not try!

There are two primary strategies to get around CAPTCHA checks:

i) Disable CAPTCHAs in your test environment

ii) Add a hook to allow tests to bypass the CAPTCHA


2) File downloads

Automating File Downloading process is not recommendable using Selenium, whilst it is possible to start a download by clicking a link with a browser under Selenium’s control, the API does not expose download progress, making it less than ideal for testing downloaded files. This is because downloading files is not considered an important aspect of emulating user interaction with the web platform.


3) HTTP response codes

Generally, selenium RC acts a proxy between the browser and the site which is being automated, which means all the traffic passing through selenium can be manipulated.

Whereas Selenium WebDriver provides a completely different approach to browser automation. It acts more like a user which is represented in the way that tester writes the test cases with WebDriver. Checking the status code is not important in automated functional testing.


4) Gmail, email and Facebook logins

For multiple reasons, logging into sites like Gmail and Facebook using WebDriver is not recommended. firstly because it is against their policy and secondly because it is slow and unreliable.

Logging in to third party sites using WebDriver at any point of your test increases the risk of your test failing because it makes your test longer.


5) Test dependency

A common idea and misconception about automated testing is regarding a specific test order.

Your tests should be able to run in any order, and not rely on other tests to complete in order to be successful.


6) Performance Testing

Performance testing using Selenium WebDriver is generally not advised. Not because it is incapable, but because it is not optimised for the job and you are unlikely to get good results.


7) Link spidering

Using WebDriver to spider through links is not a recommended practice. Not because it cannot be done, but because WebDriver is definitely not the most ideal tool for this. WebDriver needs time to start up, and can take several seconds, up to a minute depending on how your test is written, just to get to the page and traverse through the DOM.

You can use curl command or libraries like BeautifulSoup instead of WebDriver and save a lot of time.

**********************************************************************************

Selenium is an open source web testing tool that can automate browser based applications (Functionality testing, database testing, browser compatibility testing etc.).

Selenium is just not limited to that, Other than validation, we can take help of Selenium to perform some web-based administration tasks,

> Form filling
> Screen scraping
> Data extraction and transfer between applications
> Update site owners/members,
> banner upload of a site,
> Change Site Features in SPO site etc,

selenium tutorial

Worst Practices of Automated Testing using Selenium

G C Reddy

G C Reddy, Working as a Software Testing Trainer in Hyderabad, India.

You may also like...