zoukankan      html  css  js  c++  java
  • 时间控件处理

    package Page;
    
    import java.text.SimpleDateFormat;
    import java.util.Date;
    import org.openqa.selenium.*;
    import org.openqa.selenium.interactions.Actions;
    import org.openqa.selenium.support.ui.ExpectedConditions;
    import org.openqa.selenium.support.ui.WebDriverWait;
    
    import bsh.util.Util;
    
    public class DefectTodoElement {
        private static WebElement element = null;
    // 执行时处理时间
        public static void Time(WebDriver driver) {
            // Date curTimeDate = new Date();
            ((JavascriptExecutor) driver)
                    .executeScript("document.getElementById('dealTimeHandle').value ='2016-06-02 13:34:00'");
        }
    
        // 新增时发生时间
        public static void Time1(WebDriver driver) {
            Date curTimeDate = new Date();
            SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
            String date = formatter.format(curTimeDate);
            ((JavascriptExecutor) driver)
                    .executeScript("document.getElementById('dfFindTime').value ='"+date+"'");
        }
    
        // 点击时间控件
        public static void timeclick(WebDriver driver) throws InterruptedException {
            WebElement xf = driver.findElement(By.id("dfFindTime"));
            xf.click();
            Thread.sleep(500);
        }
    
        // 选择处理时间2
        public static boolean TimeNow(WebDriver driver) throws InterruptedException {
            // WebElement xf = driver.findElement(By.id("dfFindTime"));
            // xf.click();
            // Thread.sleep(1000);
            // WebElement frame =
            // driver.findElement(By.xpath("/html/body/div[3]/iframe"));
    
            for (int i = 1; i <= 20; i++) {
                try {
                    WebElement webElement = driver.findElement(By
                            .xpath("/html/body/div[" + i + "]/iframe"));
    
                    driver.switchTo().frame(webElement);
                    break;
                } catch (Exception e) {
                    continue;
                }
            }
    
            Thread.sleep(500);
            driver.findElement(By.xpath("//*[@id='dpOkInput']")).click();
            driver.switchTo().defaultContent();
            return true;
    
        }
    
        protected static void waitWebElement(WebDriver driver, String xPath,
                long timeOutSecond) {
            WebDriverWait wait = new WebDriverWait(driver, timeOutSecond);
            wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath(xPath)));
        }
    
        // 选择处理时间3
        public static void Timef(WebDriver driver) throws InterruptedException {
    
            // WebElement xf = driver.findElement(By.id("dfFindTime"));
            // xf.click();
            Thread.sleep(500);
            WebElement iframe = driver.findElement(By
                    .xpath("/html/body/div[4]/iframe"));
    
            driver.switchTo().frame(iframe);
            Thread.sleep(500);
            driver.findElement(By.xpath("//*[@id='dpOkInput']")).click();
            Thread.sleep(500);
            driver.switchTo().defaultContent();
            Thread.sleep(500);
    
        }
    }
  • 相关阅读:
    Windows远程桌面连接CentOS 7
    CentOS7 系统菜单中添加快捷方式
    CentOS 7 创建桌面快捷方式
    Centos7 可执行程序自定义为系统服务
    CentOS 7 中 Docker 的安装
    CentOS 7 需要安装的常用工具,及centos安装fcitx 搜狗输入法的坑旅
    C++中结构体与类的区别 2
    C++中结构体与类的区别 1
    C++ 11 自旋锁
    Imply.io单机安装
  • 原文地址:https://www.cnblogs.com/cmm2016/p/5595885.html
Copyright © 2011-2022 走看看