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 void takeScreenShot(String destDir,String project) | |
{ | |
// Capture screenshot. | |
File scrFile = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE); | |
// Set date format to set It as screenshot file name. | |
DateFormat dateFormat = new SimpleDateFormat("dd-MMM-yyyy__hh_mm_ssaa"); | |
// Create folder under project with name "screenshots" provided to destDir. | |
new File(destDir).mkdirs(); | |
// Set file name using current date time. | |
String destFile = project +"_"+dateFormat.format(new Date()) + ".png"; |
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 goToEndOfPage(WebDriver driver) | |
{ | |
Actions actions = new Actions(driver); | |
actions.keyDown(Keys.CONTROL).sendKeys(Keys.END).perform(); | |
} |
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
import java.text.ParseException; | |
import java.text.SimpleDateFormat; | |
import java.util.Date; | |
import java.util.concurrent.TimeUnit; | |
public class DateDifferenceCheck { | |
public static void main(String[] args) { | |
SimpleDateFormat myFormat = new SimpleDateFormat("dd MM yyyy"); | |
String inputString1 = "24 05 2016"; |
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 class GetHoursBetweenDates { | |
public static void main(String[] args) { | |
int timeAMin = toMins("12:15"); | |
int timeBMin = toMins("22:30"); | |
System.out.println(timeBMin); | |
getJourneyDuration(timeAMin,timeBMin,1,3); | |
} | |
public static int toMins(String s) { |
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
package com.demo.test; | |
import org.testng.annotations.DataProvider; | |
import org.testng.annotations.Factory; | |
import org.testng.annotations.Test; | |
public class FactoryAndDataProvider { | |
private String Source; | |
private String Desination; | |
@Factory(dataProvider = "SearchProvider") |
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
// Create instance of Javascript executor | |
JavascriptExecutor je = (JavascriptExecutor) driver; | |
//Identify the WebElement which will appear after scrolling down | |
WebElement element = driver.findElement(By.xpath("")); | |
// now execute query which actually will scroll until that element is not appeared on page. | |
je.executeScript("arguments[0].scrollIntoView(true);",element); //or | |
((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true);", element); |
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
Actions action = new Actions(driver); | |
action.sendKeys(Keys.PAGE_DOWN); |
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
=MID(A1,FIND("=",SUBSTITUTE(A1," ","=",LEN(A1)-LEN(SUBSTITUTE(A1," ",""))))+1,256) |
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
=IF((AND(MOD(E14,2)<>0,MOD(E14,3)<>0)), "Pass", "Fail") |
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
String selectLinkOpeninNewTab = Keys.chord(Keys.CONTROL,"t"); | |
driver.findElement(By.linkText("urlLink")).sendKeys(selectLinkOpeninNewTab); |
OlderNewer