美文网首页
2018-12-13接口自动化测试

2018-12-13接口自动化测试

作者: 徐俊荣 | 来源:发表于2018-12-13 13:49 被阅读0次

    package com.guoyasoft.gyautotest.ui.testCase.test;

    import com.guoyasoft.gyautotest.ui.common.BaseUI;
    import org.openqa.selenium.By;
    import org.openqa.selenium.Keys;
    import org.openqa.selenium.WebElement;
    import org.openqa.selenium.interactions.Actions;
    import org.testng.annotations.Test;
    import sun.awt.image.ImageWatched;
    import sun.security.pkcs11.Secmod;

    import javax.swing.*;

    public class TestUI extends BaseUI {
    @Test
    public void testTextInput() {
    driver.get("https://www.taobao.com/");
    WebElement text = driver.findElement(By.xpath("//input[@id='q']"));
    text.clear();
    text.sendKeys("ipad");
    sleep(2);

    }
    
    @Test
    public void testButton() {
        testTextInput();
        WebElement button = driver.findElement(By.xpath("//button[contains(text(),'搜索')]"));
        button.click();
        sleep(2);
    }
    
    @Test
    public void testlink(){
        //把网址给driver
        driver.get("https://www.taobao.com/");
        //用Xpath定位超链接(link)
        WebElement link=driver.findElement(By.xpath("//li[@aria-label=\"查看更多\"]/a[contains(text(),'女装')]"));
        //给网址加入新行动
        Actions actions=new Actions(driver);
        //按下shift 点击 弹起shift 展现
          actions.keyDown(Keys.SHIFT).click(link).keyUp(Keys.SHIFT).perform();
        //等待5秒
          sleep(5);
    
    
    }
    

    }

    相关文章

      网友评论

          本文标题:2018-12-13接口自动化测试

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