Selenium

  • 06
    Jul

    Defining data for POM pages elements

    Rules for POJO in java 1. Class needs to be Public 2. Properties are Private 3. Every property should have public getter and setters 4. Public default constructor Mandatory...

    Read More
  • 06
    Jul

    Creating a global context for your automation run

    Many a time we see scripts have to refer many global variable and modify per script execution requirements. Following code snippet allows an end user to define global variables...

    Read More
  • 06
    Jul

    XPath in Winium

    Following code snippet demonstrates how to use XPath with Winium driver. WebElement testElement = winiumdriver.findElement(By.xpath(“//*[contains(@Name,’Keys: ‘)]”)); String lblValue = testElement.getAttribute(“Name”); System.out.println(lblValue); Unfortunately Winium driver do not support CSS elements...

    Read More
  • 06
    Jul

    Get display text of label in Winium

    We can interact with Labels in desktop application by using following code: WebElement testElement = winiumdriver.findElement(By.xpath(“//*[contains(@Name,’Keys: ‘)]”)); String lblValue = testElement.getAttribute(“Name”); System.out.println(lblValue);

    Read More
  • 06
    Jul

    Launch desktop application with Winium

    Following code snippet launches desktop application – import java.io.File; import java.io.IOException; import org.openqa.selenium.winium.DesktopOptions; import org.openqa.selenium.winium.WiniumDriver; import org.openqa.selenium.winium.WiniumDriverService; public class LaunchWinium { public static WiniumDriver driver; static String outlookApplicationPath =...

    Read More
  • 06
    Jul

    Switching focus in winium

    In order to switch between two windows / apps (initialized with winium driver), one can switch between two desktop windows by using following code snippet: WebElement nextWindow = winiumdriver.findElementByName(“Window...

    Read More
  • 03
    Jul

    Creating a Maven project from Command line

    mvn archetype:generate -DarchetypeArtifactId=maven.archetype.quickstart -DgroupId=org.example -DartifactId=skeleton.web.services -DinteractiveMode=false   mvn spring-boot:run   mvn clean package¬† and java -jar target/skeleton.web.services-1.0-SNAPSHOT.jar  

    Read More
  • 27
    Jun

    How to capture screenshot in Selenium webdriver

    package Screenshot; 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.firefox.FirefoxDriver; import org.testng.annotations.Test; public class ScreenshootGoogle { @Test public void TestJavaS1() { WebDriver driver...

    Read More
  • 27
    Jun

    Executing tests in parallel with TestNG Framework

    Step 1: Create a testing.xml with parallel keyword as Step 2: create PE1 and PE2 classes (which needs to be executed in parallel) package TestNG; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver;...

    Read More
  • 26
    Jun

    select random item from drop down in selenium

    public static void selectDropDownDataRandomly(WebElement webElement) { Select dropdown = new Select(webElement); dropdown.selectByIndex(randomNumber(dropdown.getOptions().size())); } // function to get random number between 0 to number public static int randomNumber(int number) {...

    Read More