TestNG

  • 09
    Jan

    Initializing iOS or Android drivers

    public static Appiumdriver driver; AppiumServiceBuilder serviceBuilder = new AppiumServiceBuilder().usingAnyFreePort(); service=AppiumDriverLocalService.buildService(serviceBuilder); service.start(); driver = (isTargetAndroid()) ? getAndroidDriver(service.getUrl(), false, false) : getIOSDriver(service.getUrl(), false, false); where isTargetAndroid() is a private method in...

    Read More
  • 01
    Jan

    POM, PageFactory Automation framework in selenium

    WebDriver supports POM (Page Object Model) via PageFactory class.  In order to use PageFactory, all the elements needs to be declared on a PageObject as “WebElement” or “List<WebElement>” as...

    Read More
  • 28
    Dec

    Run time sendkeys in Selenium

    -For the number pad addition key. driver.FindElement(By.XPath(“String”)).SendKeys(Keys.Add); -For  the Alt key. driver.FindElement(By.XPath(“String”)).SendKeys(Keys.Alt); -For  the Left arrow key. driver.FindElement(By.XPath(“String”)).SendKeys(Keys.ArrowDown); -For  the left arrow key. driver.FindElement(By.XPath(“String”)).SendKeys(Keys.ArrowLeft); -For  the right arrow key....

    Read More
  • 26
    Dec

    Configure Timeout duration for TestNG testmethods

    TestNG allows user to configure a time period to wait for a test to completely execute. Timeout can be configured in two ways: #1. At TestMethod level: @Test(timeout=500) public...

    Read More
  • 26
    Dec

    Short notes to understand different TestNG annotations

    Annotation | Syntax | Description —————————————————————————————————————————————– @BeforeSuite | public void | The method will be run only once, before all the tests in the suite are executed. @BeforeGroups |...

    Read More
  • 26
    Dec

    Selective and Prioritized testmethod execution with TestNG

    TestNG provides features to allow selective execution of testcases based on userdefined priority. Sometimes we do not need to execute all test methods as defined in multiple test classes....

    Read More
  • 26
    Dec

    Handling Exceptions without using try/catch block with TestNG

    Like any programming language, our test cases need to be sturdy and capable to handle unexpected conditions as much as possible. e.g. While creating a temp file on detachable...

    Read More
  • 26
    Dec

    Execute selective test case to meet test requirements

    While testing it is necessary to execute “Sanityonly” test cases. e.g. As soon as build is ready, run only “sanity test cases” to validate stability of build. TestNG allows...

    Read More