美文网首页
2018-12-23 java界面自动化

2018-12-23 java界面自动化

作者: 凡星点点5 | 来源:发表于2018-12-23 17:47 被阅读0次
    package com.guoyasoft.gyautotest.ui.testCase.ycy;
    
    import com.guoyasoft.gyautotest.ui.common.BaseUI;
    import org.openqa.selenium.By;
    import org.openqa.selenium.JavascriptExecutor;
    import org.openqa.selenium.WebElement;
    import org.openqa.selenium.interactions.Actions;
    import org.openqa.selenium.support.ui.ExpectedConditions;
    import org.openqa.selenium.support.ui.WebDriverWait;
    import org.testng.annotations.Test;
    
    public class HouTai extends BaseUI{
    
        @Test
    
        public void zhixing (){
    
    //打开页面
            driver.get("https://yulegh.github.io/vue-element-test/index.html");
    //点击菜单栏组件
            driver.findElement(By.xpath("//div[contains(text(),'组件')]")).click();
    //点击双向绑定
            driver.findElement(By.xpath("//li[contains(text(),'双向绑定')]")).click();
    //切换
            driver.switchTo().frame(driver.findElement(By.xpath("//iframe[@src='component/demoDataBindTwoWay.html']")));
    //点击输入框
            driver.findElement(By.xpath("//input[@id='val1']")).click();
    //输值
            driver.findElement(By.xpath("//input[@id='val1']")).sendKeys("asd");
    //点击,点击打印
            driver.findElement(By.xpath("//button[contains(text(),'点击打印')]")).click();
    //点击弹窗确定
            driver.switchTo().alert().accept();
    
    //切换回默认页面
            driver.switchTo().defaultContent();
    //点击table
            driver.findElement(By.xpath("//div[contains(text(),'Table')]")).click();
        }
    @Test
        public void denglu(){
    
    //打开网址
            driver.get("http://blog.gdfengshuo.com/example/work/#/login");
            sleep(1);
    //点击登录
            driver.findElement(By.xpath("//span[text()='登录']")).click();
            sleep(2);
    //点击菜单栏
            driver.findElement(By.xpath("//div[@class='collapse-btn']")).click();
            sleep(1);
    //点击基础表格
            driver.findElement(By.xpath("//span[text()='基础表格']")).click();
            sleep(2);
    //点击第三个编辑按钮
            driver.findElement(By.xpath("(//span[text()='编辑'])[3]")).click();
            sleep(2);
    //清除
        driver.findElement(By.xpath("(//input[@type='text'])[5]")).clear();
    //输入地址
            driver.findElement(By.xpath("(//input[@type='text'])[5]")).sendKeys("河南省平顶山市");
            sleep(1);
    //点击确定
            driver.findElement(By.xpath("//span[text()='确 定']")).click();
    //创建鼠标属性的方法
           Actions action=new Actions(driver);
    //获取 moveToElement方法,元素定位到想要移动的元素上去
            action.moveToElement(driver.findElement(By.xpath("//div/a/i"))).perform();
            sleep(1);
    //判断未读消息,提示是否出现
        WebElement element = (new WebDriverWait(driver,5))
                .until(ExpectedConditions.presenceOfElementLocated(By.xpath("//div[contains(text(),'未读消息')]")));
        sleep(2);
    
        }
        @Test
        public void gundong(){
            driver.get("http://blog.gdfengshuo.com/example/work/#/login");
            sleep(1);
    //点击登录
            driver.findElement(By.xpath("//span[text()='登录']")).click();
            sleep(2);
    //点击菜单栏
            driver.findElement(By.xpath("//div[@class='collapse-btn']")).click();
            sleep(1);
    //定位自定义图标
            driver.findElement(By.xpath("(//span[contains(text(),'自定义图标')])[1]")).click();
    //定位文本框
            driver.findElement(By.xpath("//div[@class='content']"));
            sleep(1);
    //点击pic
            //元素滚动到固定位置
            JavascriptExecutor js=(JavascriptExecutor)driver;
            js.executeScript("arguments[0].scrollIntoView(true)",driver.findElement(By.xpath("//div/i[@class='el-icon-lx-cart']")));
            sleep(3);
    //向下滚动到底
            JavascriptExecutor jz = (JavascriptExecutor)driver;
            js.executeScript("scrollTo(0,10000)");
            sleep(1);
    

    相关文章

      网友评论

          本文标题:2018-12-23 java界面自动化

          本文链接:https://www.haomeiwen.com/subject/fwbnkqtx.html