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…
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 |
package AutoIt; import java.util.concurrent.TimeUnit; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.firefox.FirefoxDriver; import org.testng.Reporter; import org.testng.annotations.Test; /** * * @author PALLLAVI TANDALE * */ /** * UploadFile class * */ package AutoIt; import java.io.IOException; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import org.testng.annotations.Test; public class UploadFile{ WebDriver driver; @Test public void testautoit() throws Throwable { System.setProperty("webdriver.chrome.driver","E:\\chromedriver.exe"); driver=new ChromeDriver(); driver.manage().window().maximize(); driver.manage().timeouts().implicitlyWait(2000,TimeUnit.SECONDS); driver.get("http://tinyupload.com/"); driver.findElement(By.xpath("//input[@name='uploaded_file']")).click(); //runtime is a class to run Auto IT Script Runtime.getRuntime().exec("C:\\Users\\MAYUR\\Desktop\\AutoIt\\FileUpload.exe"); Thread.sleep(3000); driver.quit(); } } /** * *Auto IT Script */ ControlFocus("Open","","Edit1") Sleep(3000) ControlSetText("Open","","Edit1","C:\Users\MAYUR\Desktop\AutoIt\UploadFile.txt") Sleep(3000) ControlClick("Open","","Button1") |
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 |
package ChromeHeadless; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.chrome.ChromeOptions; import org.openqa.selenium.firefox.FirefoxBinary; import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.firefox.FirefoxOptions; /** * * @author Sarang Holey * * 10:49:00 pm */ public class BrowserHeadlessImplimentations { // creating WebDriver instance as static static WebDriver driver; public static void main(String[] args) { // calling static chrome driver headless method ChromeHeadless("https://www.facebook.com"); // calling static firefox driver headless method FirefoxHeadless("https://www.flipkart.com"); } /** * * @param URL */ public static void ChromeHeadless(String URL) { // setting up chromedriver system properties System.setProperty("webdriver.chrome.driver", "chromedriver.exe"); //creating ChromeOptions object ChromeOptions options = new ChromeOptions(); // adding arguments for activation of chrome browser in headless mode options.addArguments("--headless"); // creating ChromeDriver instance with argument to the constructor ChromeOptions instance driver = new ChromeDriver(options); // passing the URL from method argument driver.get(URL); // printing title of the given URL page of the Website System.out.println(driver.getTitle()); } /** * * @param URL */ public static void FirefoxHeadless(String URL) { // creating object of firefox binary FirefoxBinary firefoxbinary = new FirefoxBinary(); // adding the argument to activate headless mode of firefox firefoxbinary.addCommandLineOptions("--headless"); // setting up chromedriver system properties System.setProperty("webdriver.gecko.driver", "geckodriver.exe"); // creating FirefoxOptions object FirefoxOptions fo = new FirefoxOptions(); // setting up firefoxbinary fo.setBinary(firefoxbinary); // creating FirefoxDriver instance with argument to the constructor FirefoxOptions instance WebDriver driver = new FirefoxDriver(fo); // passing the URL from method argument driver.get(URL); // printing title of the given URL page of the Website System.out.println(driver.getTitle()); } } |
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 |
package TakeScreenshotReusable; import java.io.File; import java.io.IOException; import org.apache.commons.io.FileUtils; import org.openqa.selenium.OutputType; import org.openqa.selenium.TakesScreenshot; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; /** * * @author Sarang Holey * * 9:15:22 pm */ public class ScreenshotReusable { static WebDriver driver; public static void main(String[] args) { // Setting up browser properties System.setProperty("webdriver.chrome.driver", "chromedriver.exe"); // creating object of ChromeDriver with the reference of WebDriver interface driver = new ChromeDriver(); // passing the required url driver.get("https://www.google.co.in"); // calling the re-usable function for taking screenshot of current page on browser takeScreenshot("google"); } //Reusbale function for capturing screenshot with unique filename /** * * @param fileName */ public static void takeScreenshot(String fileName) { // capturing screenshot as output type file from getScreenshotAs method by up casting the WebDriver reference to TakeScreenshot Interface File file = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE); try { // Coping screenshot file into Screenshots folder with Filename from argument along with current time appended to file name FileUtils.copyFile(file, new File("../TakeScreenshot/src/test/resources/Screenshots/"+fileName+""+System.currentTimeMillis()+".png")); } catch (IOException e) { // catching the exception while file handling e.printStackTrace(); } } } |
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 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…
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 |
package SeleniumSessions.DatePicker; import java.util.concurrent.TimeUnit; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; /** * @author Sarang * @Date - 21/05/2019 */ public class DatePickerOnGoIbibo { WebDriver driver; String URL = "https://www.goibibo.com/"; String MonthToBeSelected = "September 2020"; String DAY = "15"; @BeforeMethod public void setup() { System.setProperty("webdriver.chrome.driver", "chromedriver.exe"); driver = new ChromeDriver(); driver.manage().window().maximize(); driver.manage().deleteAllCookies(); driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS); } @Test public void datePicker() throws InterruptedException { // passing URL driver.get(URL); // Clicking on Departure Date Picker Box driver.findElement(By.xpath("//input[@type='text' and @placeholder='Departure']")).click(); // Logic for Expected Date Picker while (true) { String monthOnPage = driver.findElement(By.xpath("//div[@class='DayPicker-Caption' and @role='heading']")).getText(); if (monthOnPage.equals(MonthToBeSelected)) { break; } else { driver.findElement( By.xpath("//span[@role='button' and @class='DayPicker-NavButton DayPicker-NavButton--next']")).click(); } } // Clicking over the DAY variable date driver.findElement(By.xpath("//div[@class='DayPicker-Week']/div[@class='DayPicker-Day']/div[text()=" + DAY + "]")).click(); } @AfterMethod public void teardown() { driver.close(); } } |
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…
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 |
package SeleniumSessions; 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; /** * * @author Sarang * Created on 16/04/2019 * */ public class AuthenticationURL { public static void main(String[] args) { // WebDriver Configuration System.getProperty("webdriver.chrome.driver", "chromedriver.exe"); WebDriver driver = new ChromeDriver(); driver.manage().window().maximize(); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); //Here inside URL USername and Password is being sent // Username - admin // Password - admin // after text http://username:password@Url is to be the syntax driver.get("http://admin:admin@the-internet.herokuapp.com/basic_auth"); // Validation Check Point WebElement successfulAuthText = driver.findElement(By.xpath("//div[@id='content']//p")); System.out.println(successfulAuthText.getText()); String ActualText ="Congratulations! You must have the proper credentials."; if(successfulAuthText.equals(ActualText)) { System.out.println("Authentication is successful"); } else { System.out.println("Authentication is Unsuccessful"); } } } |
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 |
package SeleniumSessions; import org.openqa.selenium.By; import org.openqa.selenium.Keys; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.interactions.Actions; import org.testng.Assert; import org.testng.annotations.Test; /** * * @author Sarang * Created on 19/04/2019 * */ public class KeyPressEventInSelenium { static WebDriver driver; @Test public void keyPressEventSpace() throws InterruptedException { System.setProperty("webdriver.chrome.driver", "chromedriver.exe"); driver = new ChromeDriver(); driver.get("http://the-internet.herokuapp.com/key_presses"); Actions action = new Actions(driver); action.sendKeys(Keys.SPACE).build().perform();; String text = driver.findElement(By.id("result")).getText(); System.out.println(text); Assert.assertEquals(text, "You entered: SPACE"); Thread.sleep(2000); driver.quit(); } @Test public void keyPressEventEnter() throws InterruptedException { System.setProperty("webdriver.chrome.driver", "chromedriver.exe"); driver = new ChromeDriver(); driver.get("http://the-internet.herokuapp.com/key_presses"); Actions action = new Actions(driver); action.sendKeys(Keys.ENTER).build().perform();; String text = driver.findElement(By.id("result")).getText(); System.out.println(text); Assert.assertEquals(text, "You entered: ENTER"); Thread.sleep(2000); driver.quit(); } } |