sdet training || sdet course

5 min read

How To Write And Run A Test Case In Selenium?

One of the most popular automated testing frameworks in the software engineering world is now Selenium. The Selenium toolkit, which includes the IDE, RC, WebDriver, and Grid, has quickly become the industry standard for test automation.

Selenium capitalised on the drawbacks of earlier frameworks like Mercury's Astra QuickTest and HP QTP, which required users to create VBScript scripts and were mainly designed for desktop-based tests. Additionally, it is well-liked by both independent testers and businesses like Netflix, Google, HubSpot, and Fitbit because to its support for a variety of languages, including Java, Python, C#, Perl, Ruby,.net, and PHP.

In order to do away with the necessity for users to undertake repetitive manual testing, Jason Higgins founded Selenium in 2004. Now let's talk about writing test cases in Selenium so that we can benefit from its capacity to deliver complete, accurate test coverage in a brief period of time.

Test Case in Selenium

All programme must undergo end-to-end testing prior to release. This technique simulates multiple user scenarios from beginning to end in order to test the application workflow. When doing an end-to-end test, the first step is to analyse the business requirements. The tester who may have been trained with SDET course, then takes into account the many user personas involved, aims for maximum test coverage, and considers employing automation to do it.

The tester often starts the process by studying the business requirements to identify a collection of user stories. What a product user would like to be able to perform is represented by these user stories, which also help to describe business requirements. This thus helps to create a number of test scenarios and cater to a variety of user personas..

After the test scenarios are framed, a set of best practises adopted by the entire industry is used to turn them into a series of actions that can aid in the verification of a certain functionality. An example of this is a test case. In the context of software testing, a test case is the series of procedures needed to confirm a specific feature or functionality. The test case provides information on the procedures, inputs, conditions, and outputs required to validate a feature. Additionally, it will outline particular parameters in order for QAs to compare predicted and actual outcomes in order to assess whether the feature works as intended.

The test case components mention input, execution, and anticipated output/response. In essence, it gives engineers instructions on what to do, how to accomplish it, and what outputs are acceptable.

Tips for Writing the Best Test Cases

  1. Prioritizing clarity and transparency is important. When defining what the tester must perform and the anticipated outcomes, be precise, concise, and assertive.
  2. Bear in mind the needs of the end user when developing sample test cases. Every step of the user journey should be reflected in the test cases. Consult the Documents for Specifications and Requirements to do this.
  3. Avoid repetition wherever possible. Refer to the critical test case identified by the Test Case ID if numerous tests can be executed using the same test case.
  4. Try to minimise the number of test steps. Limit yourself to no more than 10 to 15 steps.
  5. Focus on getting 100% test coverage. Although complete test coverage is uncommon, a large proportion can be attained with the appropriate techniques.
  6. Create test scenarios that are self-cleaning. The Test Environment must be returned to its initial, pre-test state by the test cases. There should be no traces of the tests in the environment after they are finished. This plays a crucial role in configuration management.

Example of writing and running a test case in selenium

  1. Choose New -> Package by right-clicking the src folder.

sdet training

  1. Click "Finish" after entering a package name, such as "com.dla.test"

sdet training || sdet course

  1. New -> Class can be chosen by right-clicking the newly formed package.

sdet training || sdet course

  1. Enter "DLARegistrationTest" as the class name and click Finish.

sdet training || sdet course

  1. After completing the test, right-click on it and select RunAs.
  2. After running the test, select the project and press F5 to refresh it.

sdet training || sdet course

7. A new folder called "test-results" will be created to store the execution results. Right-click on index.html and choose "Open with"->"Web Browser" to view the execution report.

Folow us with more links :-

Follow Us On Facebook :- https://www.facebook.com/devlabsalliance

Folow Us On Linkedin :- https://www.linkedin.com/company/devlabsalliance/

Follow Us On YouTube :- https://www.youtube.com/channel/UC8nOZvcKnVKRPG4yPXLXYZQ/

Contact Us :- +91 7428334555

Email Us :- training@devlabsalliance.com

Address:- Unit No. DCG4 – 2216, DLF Corporate Green, Sector-74A, Gurgaon, Haryana – 122004, INDIA

In case you have found a mistake in the text, please send a message to the author by selecting the mistake and pressing Ctrl-Enter.
Devlabs Alliance 2
Joined: 10 months ago
Comments (0)

    No comments yet

You must be logged in to comment.

Sign In / Sign Up