自动化测试随笔1

 1 public class Common {
 2 
 3 public static String getCurrentTime(){
 4 
 5 Date now = new Date(); 
 6 SimpleDateFormat dateFormat = new SimpleDateFormat("ss");
 7 String currentTime = dateFormat.format(now); 
 8 return currentTime;
 9 }
10 
11 public static WebElement waitForElement(WebDriver driver,By by){
12 WebDriverWait wait = new WebDriverWait(driver, 30);    
13 WebElement element = wait.until(ExpectedConditions.elementToBeClickable(by));
14 return element;
15 }
16 
17 
18 public static WebElement scrollToElement(WebDriver driver,By by){
19 WebElement element = Common.waitForElement(driver, by);
20 JavascriptExecutor scroll = (JavascriptExecutor) driver;
21 scroll.executeScript("arguments[0].scrollIntoView();", element);
22 return element;
23 }
24 
25 
26 
27 
28 }
原文地址:https://www.cnblogs.com/by170628/p/7094480.html