Skip to main content

Posts

Creating fully functional page object model automation framework with Playwright in 1 hour

 We are back with another 1hour tutorial  😇 . This time we will be creating Playwright and Typescript page object model framework. For this we will be using Visual Studio Code editor. Hope you have a basic idea on Playwright. There are plenty of resources you can refer to get the basic idea of the Playwright. In this tutorial we will be focussing more on how to implement Page Object model in Playwright. So let's begin. Before all of this, you must need to have  node js  installed. I hope you have already done that. 1. Download the relevant nodejs packages by using following command  npm init playwright@latest 2. Lets create our project structure. Unlike Selenium 1 hour lesson for this we will be creating just two folders. To write page objects we use "pages" folder and to write tests we create "tests" folder. Just for now, run the default tests which Playwright automatically create with its installation. use  npx playwright test command in your CMD. By default
Recent posts

Creating a fully functional page object model automation framework with Selenium in 1 hour

In this tutorial we will check how to create a simple Selenium/ Testng page object model framework with reporting and logging capabilities. For this I'm using Intellij idea IDE Community version because of its amazing debugging capabilities. Also I'm using Maven, Selenium with Testng with log4j. Let's begin, 1. Create a Maven project using intellij IDE. 2. Prepare the project structure as follows, There should be 4 folders/packages to handle functions, pages, resources and test cases.  Before that delete the existing auto org.example folders in both main and test folders. Then created following folders as below. 3. Now we need to download all the necessary packages we need to use in this project. Paste following mvn dependencies in your pom.xml file within <dependencies></dependencies> tags. before that remove this junit dependency which is already coming automatically because we don't need it. <dependency> <groupId> junit </groupId>

Complex scenarios automation in Selenium- Part 1

So for this exercise we will be clicking an any state in this SVG map. https://petdiseasealerts.org/forecast-map#/ So for this exercise, the best chance you getting a valid result is getting the correct xpath. So most of you will get this xpath. String stateXpath = "(//*[name()='svg'])/*[@id='features']/*[@id='regions']/*[@id='" +state+ "']" ; or this String stateXpath= "//*[name()='svg']//*[name()='g' and @id = ' " +state+ " ']" ; with one of this implementations if you ran following code, you will fail at state Florida, with element click intercept exception. package org.example ; import io.github.bonigarcia.wdm.WebDriverManager ; import org.openqa.selenium.By ; import org.openqa.selenium.JavascriptExecutor ; import org.openqa.selenium.WebDriver ; import org.openqa.selenium.chrome.ChromeDriver ; import org.openqa.selenium.chrome.ChromeOptions ; import org.openqa.selenium.support.ui.Expecte