DEV Community

Revathy
Revathy

Posted on • Updated on

Selenium for automation

___ Selenium :__
Selenium is an opensource project so many people work together to bring up that project. It can automate a browser, the way we automate is in our hands.

For example, for a Facebook application to upload a profile picture everyday whenever we login and share it. This can be achieved by selenium automation, but we cannot use selenium outside the browser everything has to be done on browser itself.

It is functional for all browsers, works on all major OS and its scripts are written in various languages like Python, Java, C#, etc., Selenium is combination of tools and DSL (Domain Specific Language) in order to carry out various types of tests.

With Selenium Python, we can write robust test scripts to automate the testing of web applications, ensuring their functionality across different browsers and platforms.

The Selenium server runs tests on various browsers, it can Google Chrome, Internet Explorer, Mozilla, Firefox, or Safari.

Developers and testers can even run tests in parallel on multiple combinations, helping them to ship quality builds at light speed.

The Selenium test scripts can be integrated with tools such as TestNG and JUnit for managing test cases and generating reports.

It can also be integrated with Maven, Jenkins, and Docker to achieve continuous testing.

Advantages:

  1. Faster execution
  2. More accurate
  3. Lesser investment in human effort
  4. Supports regression testing
  5. Frequent execution
  6. Supports Lights out Execution

Versions of selenium:

  • Selenium 1: Selenium core with java script injection

  • Selenium 2: selenium with web driver and RC

  • Selenium 3: Selenium web driver and updated components

  • Selenium 4: Selenium with W3c protocol, web drivers and
    other updated components

*Components of selenium *

WebDriver:

On beginning with desktop website or mobile website test automation, then we are going to be using WebDriver APIs. WebDriver uses browser automation APIs provided by browser vendors to control the browser and run tests.

This is as if a real user is operating the browser. Since WebDriver does not require its API to be compiled with application code, it is not intrusive. Hence, testing the same application which we push live.
Enter fullscreen mode Exit fullscreen mode

IDE:
IDE (Integrated Development Environment) is the tool you use to develop your Selenium test cases. It’s an easy-to-use Chrome and Firefox extension and is generally the most efficient way to develop test cases.

It records the users’ actions in the browser for you, using existing Selenium commands, with parameters defined by the context of that element.

RC:
RC is the remote control in which the server has to run before starting the automation process, it has thrown many disadvantages to later it was deprecated in later versions of selenium.

Grid:
Selenium Grid allows us to run test cases in different machines across different platforms. The control of triggering the test cases is on the local end, and when the test cases are triggered, they are automatically executed by the remote end.

After the development of the WebDriver tests, we may face the need to run your tests on multiple browsers and operating system combinations.

This is where Grid comes into the picture. It is not always advantageous to automate test cases:

    There are times when manual testing may be more appropriate. For instance, if the application’s user interface will change considerably in the near future, then any automation might need to be rewritten anyway. 


   Also, sometimes there simply is not enough time to build test automation. For the short term, manual testing may be more effective. 

     If an application has a very tight deadline, there is currently no test automation available, then manual testing is the best solution.
Enter fullscreen mode Exit fullscreen mode

Functional testing is challenging to get right for many reasons. As if application state, complexity, and dependencies do not make testing difficult enough, dealing with browsers makes writing good tests a challenge.

Selenium provides tools to make functional user interaction easier but does not help us write well-architected test suites.

 Functional end-user tests such as Selenium tests are expensive to run, however. Further, they typically require substantial infrastructure to be in place to be run effectively. 
Enter fullscreen mode Exit fullscreen mode

A distinct advantage of Selenium tests is their inherent ability to test all components of the application, from backend to frontend.

Those tests can be expensive to run. To what extent depends on the browser you are running the tests against, but historically browsers’ behavior has varied so much that it has often been a stated goal to cross-test against multiple browsers.

 It allows us to run the same instructions against multiple browsers on multiple operating systems, but the enumeration of all the possible browsers, their different versions, and the many operating systems they run on will quickly become a non-trivial undertaking.
Enter fullscreen mode Exit fullscreen mode

Top comments (0)