From the course: Selenium Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Clean up the test

Clean up the test - Selenium Tutorial

From the course: Selenium Essential Training

Start my 1-month free trial

Clean up the test

- [Instructor] Let's focus on cleaning up the steps in the test to make them more readable. Readability of a test is important so that it is clear what the test is doing. I'm going to focus on extracting similar functionality and behavior into methods. The first set of steps that I'll focus on are from lines 19 to 34. All of those steps focus on submitting the form. There are many steps here but I can go ahead and condense those steps down into one single method which can submit the form. To do that, I'll start by copying lines 19 to 34 and then I can cut those lines. And then after the main method of my test, I will declare a new method by typing public static void submitForm, which is the name of the method. And this method will take WebDriver driver as the parameter. In the body of this method, I will paste those lines from above that submit the form. Now going back up to the test, on line 19 I can call submitForm, passing in the driver as a parameter in order to call those lines…

Contents