This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AndroidDriver<MobileElement> driver; | |
@BeforeClass | |
public void setup() throws IOException, InterruptedException{ | |
//startAppiumServer(); | |
File appDir = new File("src"); | |
File app = new File(appDir,"app.apk"); | |
DesiredCapabilities cap =new DesiredCapabilities(); | |
cap.setCapability(MobileCapabilityType.PLATFORM_NAME, MobilePlatform.ANDROID); | |
cap.setCapability(MobileCapabilityType.PLATFORM_VERSION, "5.1"); | |
cap.setCapability(MobileCapabilityType.DEVICE_NAME, "Moto E"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ArrayList<String> tabs = new ArrayList<String> (driver.getWindowHandles()); | |
driver.switchTo().window(tabs.get(1)); | |
driver.manage().timeouts().pageLoadTimeout(20, TimeUnit.SECONDS); | |
String actUrl = driver.getCurrentUrl(); | |
driver.close(); | |
driver.switchTo().window(tabs.get(0)); | |
Thread.sleep(2000); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static WebDriver driver; | |
@BeforeClass | |
public void setup() throws InterruptedException{ | |
System.setProperty("webdriver.chrome.driver", "C:\\QASetup\\chromedriver.exe"); | |
HashMap<String, String> mobileEmulation = new HashMap<String, String>(); | |
mobileEmulation.put("deviceName", "Google Nexus 5"); | |
Map<String, Object> chromeOptions = new HashMap<String, Object>(); | |
chromeOptions.put("mobileEmulation", mobileEmulation); | |
DesiredCapabilities capabilities = DesiredCapabilities.chrome(); | |
capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void hideKeyBoard(AndroidDriver<MobileElement> driver){ | |
driver.getKeyboard(); | |
driver.hideKeyboard(); | |
driver.pressKeyCode(AndroidKeyCode.BACK); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void setDate2(AndroidDriver<MobileElement> driver,String month,int date){ | |
month = month.substring(0, 3); | |
List<MobileElement> ele = driver.findElements(By.id("android:id/numberpicker_input")); | |
ele.get(0).click(); | |
List<MobileElement> eles = driver.findElements(By.className("android.widget.Button")); | |
System.out.println(eles.size()); | |
while(! (ele.get(0).getAttribute("name").equals(month))){ | |
eles.get(1).click(); | |
} | |
ele.get(1).click(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static final By DATE_FIELD = By.id("com.confirmtkt.lite:id/datelinearlayout"); | |
public static final By DATE_PICKER_2 = By.className("android.view.View"); | |
public static final By DATE_CANCEL = By.id("android:id/button2"); | |
public static final By DATE_PICKER = By.id("android:id/date_picker_day"); | |
public static final By MONTH_PICKER = By.id("android:id/date_picker_month"); | |
public static final By YEAR_PICKER = By.id("android:id/date_picker_year"); | |
public static final By DATE_OK = By.id("android:id/button1"); | |
public static void setDate(AndroidDriver<MobileElement> driver,int reqDateNum, String reqMonth, int reqYear) throws ParseException{ | |
boolean isDateSet = false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@AfterMethod | |
public void onTestFailure(ITestResult result) { | |
String testName = result.getMethod().getMethodName().toUpperCase(); | |
if (ITestResult.FAILURE == result.getStatus()) | |
takeScreenShot(driver, "Sanity\\Failed\\"+testName+"","Project_name"); | |
else if (ITestResult.SUCCESS == result.getStatus()) | |
takeScreenShot(driver, "Sanity\\Passed\\"+testName+"","Alternates"); | |
else | |
takeScreenShot(driver, "Sanity\\Skipped\\"+testName+"","Alternates"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public String getTodayDate(String format){ | |
DateFormat df = new SimpleDateFormat(format); | |
Calendar calobj = Calendar.getInstance(); | |
String CurrentDate = df.format(calobj.getTime()); | |
return CurrentDate; | |
} | |
public String getNextDays(String format,int noDays) throws ParseException{ | |
DateFormat df = new SimpleDateFormat(format); | |
Calendar calobj = Calendar.getInstance(); | |
String CurrentDate = df.format(calobj.getTime()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WebDriver driver; | |
@BeforeClass | |
public void setup() throws ParseException{ | |
System.setProperty("webdriver.chrome.driver", "C:\\QASetup\\chromedriver.exe"); | |
ChromeOptions options = new ChromeOptions(); | |
options.addArguments("--disable-extensions"); | |
options.addArguments("--no-sandbox"); | |
driver = new ChromeDriver(options); | |
driver.manage().window().maximize(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static int getIntvalue(String text){ | |
int value = Integer.parseInt(text.replaceAll("\\D+","")); | |
return value; | |
} |
NewerOlder