Skip to main content

SELENIUM-TestNG - Prioritizing the tests

Managing Priorities in TestNG 


Prioritizing the tests using TestNG and Enabling, Disabling the Testcases & adding Time.

package packTwo;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
public class DependenyAnnot{
@Test
public void OpeningBrowser()
{
System.out.println("Executing Opening Browser"); 
 }
@Test(dependsOnMethods={"OpeningBrowser"}, alwaysRun=true) //If Flight Booking Method depends on Opening Browser Method. Even if OpeningBrowse testcase fails but you still want to execute FlightBooking testcase then use command alwaysRun =True
public void FlightBooking()
{
System.out.println("Executing Flight Booking");
}
@Test(timeOut=5000)//If a TestCase is required to complete in some time, here if complete execution does not happen in 5000 millisecond script will fail.
public void Timerelated()
{
System.out.println("Time TestCase");
}
@Test(enabled=false) //If you don't want to include any Testcase into the report OR don't want to execute the Testcase.
public void Payment()
{
System.out.println("Executing Payment");
}
}

Comments

Popular posts from this blog

SELENIUM -Screen Shot

SELENIUM - Screen Shot public class Guru99TakeScreenshot  { @Test public void testGuru99TakeScreenShot() throws Exception { WebDriver driver; System.setProperty ("webdriver.chrome.driver","C:\\Selenium_Projects\\Geo_Driver\\chromedriver.exe" ); driver = new ChromeDriver(); //goto url driver.get("http://demo.guru99.com/V4/");  //Call take screenshot function  takeSnapShot(driver,"c://Selenium_Projects//test.png") ;      }     /**      * This function will take screenshot      * @param webdriver      * @param fileWithPath      * @throws Exception      */ public static void takeSnapShot(WebDriver webdriver,String fileWithPath) throws Exception { //Convert web driver object to TakeScreenshot TakesScreenshot scrShot =((TakesScreenshot)webdriver); //Call getScreenshotAs method to create image file File SrcFile=scrShot.getScreenshot...

Running Appium Server Programatically

Running Appium Server Programatically Here is how to trigger the Appium server through java and will initiate appium server programatically as soon as you run your appium Test. 1. Go to appium folder here node.exe will help us to run the appium server. Node.exe takes argument from node.js file. 2. Go to node_modules >> appium >> bin >> appium.js is the file responsible to trigger the appium server. 3. Give this command in cmd 1st argument is location for node.exe and 2nd argument is of appium.js, here 1st argument triggers the 2nd argument. "C:\Appium\node.exe" "C:\Appium\node_modules\appium\bin\appium.js" This is open up Appium server. 4. To make this work from code Copy past "C:\Appium\node.exe" "C:\Appium\node_modules\appium\bin\appium.js" and save this command in notepad as "startappium.bat" in C folder. 4. Now you need to run this file from java code in eclipse. Runtime.getRuntime()....