Use of Page Methods to Make Selenium Code Re-usable

In this post, you will learn kind of coding pattern which is very helpful in maintaining our automation code. This post is written insight to help beginners. We'll learn that instead of writing a linear script, we should create page (action) methods which in general contain actions which we are going to perform on our web software. 

Let's say, we have a login functionality in our software and we have to automate it. In that case we'll create a method named login and write the commands like, entering username, password and click login in that method. Now we can use that method wherever we need it in other test cases as well. Benefits of using action methods are:

  • Code Re-usability
  • Better maintainability of code
Sharing below a sample script, in which I'm entering data in a web form using action methods:




Thanks for reading, share your thoughts in comments. Happy Learning! :)


Author: Vaneesh Behl
Join Telegram channel of this blog at https://t.me/techlisticspace

Comments

  1. Really it was an awesome article...very interesting to read..You have provided an helpful programming....Thanks for sharing.. Java online training

    ReplyDelete

Post a Comment

Popular Posts

Top 10 Demo Websites to Practice Selenium Webdriver Online

Selenium Essentials - How to become expert in Automation Testing?

Top 25 Must to know Selenium Webdriver Commands List

Selenium WebDriver - Browser and Navigation Commands

Selenium IDE - Sample Script With Most Commonly Used Commands