This is a many part series. More videos pertaining to this will be added. Complete You tube playlist:
Video Tutorial: GitHub Repo: https://github.com/akashdktyagi/AutoFratCommonLib Code: Runner File:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
package runner; import org.junit.runner.RunWith; import cucumber.api.CucumberOptions; import cucumber.api.junit.Cucumber; @RunWith(Cucumber.class) @CucumberOptions ( features="classpath:features", glue="", tags="", plugin = {"pretty", "html:target/html/", "json:target/json/file.json", "com.aventstack.extentreports.cucumber.adapter.ExtentCucumberAdapter:"}, dryRun=false ) public class RunTest { } |
2. Step Defs:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
package stepdefs; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import cucumber.api.Scenario; import cucumber.api.java.Before; import cucumber.api.java.en.Given; public class StepDefs { Scenario scenario; @Before public void SetUp(Scenario s) { scenario = s; } @Given("I open the Browser and Navigate to the URL {string}") public void i_open_the_Browser_and_Navigate_to_the_URL(String string) { WebDriver driver = new ChromeDriver(); driver.get(string); scenario.write("Opened the Browser with URL: " + string); } } |
3. POM File:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.visionit</groupId> <artifactId>CanBeDeleted</artifactId> <version>0.0.1-SNAPSHOT</version> <properties> <cucumber.version>4.2.0</cucumber.version> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> </properties> <build> <plugins> <plugin> <artifactId>maven-surefire-plugin</artifactId> <version>3.0.0-M1</version> <configuration> <parallel>methods</parallel> <threadCount>2</threadCount> <perCoreThreadCount>false</perCoreThreadCount> <!-- <useUnlimitedThreads>true</useUnlimitedThreads>--> <argLine>-Xmx1024m -XX:MaxPermSize=256m</argLine> </configuration> </plugin> </plugins> </build> <!-- For Cucumber --> <dependencies> <dependency> <groupId>io.cucumber</groupId> <artifactId>cucumber-java</artifactId> <version>${cucumber.version}</version> <scope>test</scope> </dependency> <dependency> <groupId>io.cucumber</groupId> <artifactId>cucumber-junit</artifactId> <version>${cucumber.version}</version> <scope>test</scope> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> <scope>test</scope> </dependency> <!-- For dependency Injection --> <dependency> <groupId>io.cucumber</groupId> <artifactId>cucumber-picocontainer</artifactId> <version>${cucumber.version}</version> <scope>test</scope> </dependency> <dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-java</artifactId> <version>3.141.59</version> </dependency> <!-- For Extent Reports --> <!-- Extent Report Adapter for Cucumber --> <dependency> <groupId>com.aventstack</groupId> <artifactId>extentreports-cucumber4-adapter</artifactId> <version>1.0.7</version> </dependency> <!-- https://mvnrepository.com/artifact/com.aventstack/extentreports --> <dependency> <groupId>com.aventstack</groupId> <artifactId>extentreports</artifactId> <version>4.0.9</version> </dependency> <!-- https://mvnrepository.com/artifact/org.freemarker/freemarker --> <dependency> <groupId>org.freemarker</groupId> <artifactId>freemarker</artifactId> <version>2.3.28</version> </dependency> <!-- https://mvnrepository.com/artifact/org.mongodb/mongo-java-driver --> <dependency> <groupId>org.mongodb</groupId> <artifactId>mongo-java-driver</artifactId> <version>3.10.2</version> </dependency> </dependencies> </project> |
Steps to take: Create account in Git Hub. https://github.com/ Note down user name, email and password. Down load git from git-scm…
Automation Framework design patterns: Before we understand Automation Design patterns we first need to understand the components of an Automation…
This is a recording of class room sessions. During these session we will be covering FW creation using Cucumber and…
This is a recording of multiple class rooms lectures. Artifacts/code is kept in git at below locations: Best Buy API…
This is a multi part series of videos and tutorials. Most of these sessions are recorded during the live class…
This is a sample project to automate rest full API. Will add more such code and tutorial coming forward. POM.XML…
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
package dev.backup.akash.codesnippets; import java.util.concurrent.TimeUnit; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.interactions.Actions; import org.testng.Assert; public class HandlingMegaMenuAmazon { public static void main(String[] args) { System.setProperty("webdriver.chrome.driver", "C:\\Users\\Devina\\Downloads\\chromedriver_win32\\chromedriver.exe"); //1 Create Driver object WebDriver driver = new ChromeDriver(); driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); //Navigate and click on the link driver.get("https://www.amazon.in/"); HandleMegaMenu_SelectItems(driver,"Mobiles, Computers","Tablets"); } public static void HandleMegaMenu_SelectItems(WebDriver driver, String category, String sub_category) { //Get shop-all element and hover on it by using Actions Class WebElement shop_all = driver.findElement(By.id("nav-link-shopall")); //Use Actions class for mouse over Actions action = new Actions(driver); action.moveToElement(shop_all).build().perform(); //Find the Category element and mouse over it //WebElement category_element = driver.findElement(By.xpath("//span[@class='nav-text' and text()='Fire TV Stick']")); WebElement category_element = driver.findElement(By.xpath("//span[@class='nav-text' and text()='" + category + "']")); action.moveToElement(category_element).build().perform(); //Find the Sub Category element and click //WebElement category_element = driver.findElement(By.xpath("//span[@class='nav-text' and text()='Fire TV Stick']")); WebElement sub_category_element = driver.findElement(By.xpath("//span[@class='nav-text' and text()='"+ sub_category +"']")); sub_category_element.click(); //Valdiation here using page titles or some page header } } |
Code to find all broken links in a web page. Broken links are the links which navigates no where, i.e.…
Open Url: https://www.flipkart.com (Do not Login) and validate the page is opened by checking the title and a page locator. Search…
What is A FW A FW is a blueprint or a set of guidelines to organize the code. It tells…
This can be explained as a Challenging Scenario in interviews as below: “UI-DB validation: I faced a scenario where I…
Perfect Example of why you need Abstraction is: WebDriver driver = new ChromeDriver(); In above line “WebDriver” is an interface…
Below is the code for JDBC MySQl connection and reusable method which return 2 D array. GitHub location: https://github.com/akashdktyagi/AutomationPoCCucumber/tree/master/src/test/java/bddcucumber/managers/dbmanager Code:…
In this three part video sessions, I have explained how to create the new feature file and their respective step…
Cucumber with Java Tutorial and Framework. Cucumber Framework Demo Video: Below is a complete Cucumber tutorial and base framework kept…
Below are the List of all top level test cases for Testing a Health Care Domain Application. For each test…
Selenium Web Table Handling using XPATH and XPATH Axes
This is a basic automation test to automate zero app
Framework Development Part 4-All about Git and how to use Git in a Live Team Set Up Check for the…
Check for the Latest copy of the Framework here at git hub: https://github.com/akashdktyagi/AutomationPoCFW Part 3: This video contains Discussion around…
Extent Report Implementation using new Extent Report TestNG ITest Listener. Check for the Latest copy of the Framework here at…
This is a many part videos to create a working Selenium test automation framework to automate a retail banking application.…
Navigate to URL: https://ca.ingrammicro.com Search for product: Apple Assert that search result is displayed. Create a method which takes arrays of…
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
public String TakeScreenShot(WebDriver driver) { try { //Get the random number for the file Random rand = new Random(); long random = (int )(Math.random() * 999999999 + 1000000); String result = Long.toString(random); String path = System.getProperty("user.dir") + "//" +"ScreenShots"; String nameFileName = result + ".png"; String filePathName = path + "//" + nameFileName; //to create new folder new File(path).mkdirs(); // TODO Auto-generated method stub TakesScreenshot scrShot = (TakesScreenshot)driver; File srcFile = scrShot.getScreenshotAs(OutputType.FILE); File destFile = new File(filePathName); Files.copy(srcFile.toPath(), destFile.toPath()); //WriteLogAndReport(logger, "info", "info", "Screen Shot taken at location: " + path); //Reporter.log("Screen shot taken and kept at path: " + filePathName ); Reporter.log("<a href = '" +filePathName + "'>My ScreenShot link</a>"); return filePathName; }catch (Exception e) { e.printStackTrace(); return null; } } |
Below Scenario is to Validate the Search functionality of an E Commerce Web Site: URL: https://ca.ingrammicro.com/ Below Code demonstrate three…
This Scenario can be mentioned as an answer to the Question : Explain a challenging scenario/task you recently faced and…
Driver Class: To create standalone jar to distribute. Please note that This class will not be used for execution…