Helper Class
=========
package com.businesshelper1;
import java.util.List;
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.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.FluentWait;
import org.openqa.selenium.support.ui.Wait;
import org.openqa.selenium.support.ui.WebDriverWait;
public class Helper {
public static WebDriver driver;
public static String driverpath="D:\\SeleniumJar_08_28_2020\\chromedriver_win32 (4)\\chromedriver.exe\\";
public static String url="https://www.google.com/webhp?authuser=3";
/**
* This Method is used to launch App
*
*/
public static void launchApp(){
System.setProperty("webdriver.chrome.driver", driverpath);
driver=new ChromeDriver();
driver.get(url);
maxmizeBrowser();
}
/**
* This Method is used to max browser
*
*/
public static void maxmizeBrowser(){
driver.manage().window().maximize();
}
/**
* This Method is used to close borwser
*
*/
public static void closeBrowser(){
driver.close();
}
/**
* This Method is used to compare String
* @param actual is String Type
* @param Expected is String Type
*/
public static void compareString(String actual,String expected){
if(actual.equals(expected)){
System.out.println("************ Test Cased is passed ***********");
}
else{
System.out.println("************ Test Cased is Failed ***********");
}
}
/**
* This Method is used to Select RadioButton & Checkbox
* @param WebElemet is ele para
*
*
*/
public static WebElement veifySelected(WebElement ele){
ele.click();
boolean status=ele.isSelected();
if(status){
//System.out.println("Radio button is selected");
System.out.println("Check box is selected");
}
else{
//System.out.println("Radio button is not selected");
System.out.println("Check box is selected");
}
return ele;
}
/**
* This Method is used to wait certain amount of time
* @param integer type
*
*
*/
public static void implicitWait(int a){
driver.manage().timeouts().implicitlyWait(a, TimeUnit.SECONDS);
}
/**
* This Method is used to wait specific Element
* @param integer type
*
*
*/
public static WebElement explicityWait(WebDriver driver,int a,String str){
WebDriverWait wait=new WebDriverWait(driver, a);
return wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(str)));
}
/**
* This Method is used to Fluent Wait
* @param integer type
*
*
*/
public static WebElement fluentWait(WebDriver driver,int a,int b,String xpath ){
Wait<WebDriver> wait =new FluentWait(driver)
.withTimeout(a,TimeUnit.SECONDS)
.pollingEvery(b,TimeUnit.SECONDS)
.ignoring(NoSuchFieldException.class);
return wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(xpath)));
}
}
No comments:
Post a Comment