2018-12-13接口自動(dòng)化測試

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("http://input[@id='q']"));
text.clear();
text.sendKeys("ipad");
sleep(2);

}

@Test
public void testButton() {
    testTextInput();
    WebElement button = driver.findElement(By.xpath("http://button[contains(text(),'搜索')]"));
    button.click();
    sleep(2);
}

@Test
public void testlink(){
    //把網(wǎng)址給driver
    driver.get("https://www.taobao.com/");
    //用Xpath定位超鏈接(link)
    WebElement link=driver.findElement(By.xpath("http://li[@aria-label=\"查看更多\"]/a[contains(text(),'女裝')]"));
    //給網(wǎng)址加入新行動(dòng)
    Actions actions=new Actions(driver);
    //按下shift 點(diǎn)擊 彈起shift 展現(xiàn)
      actions.keyDown(Keys.SHIFT).click(link).keyUp(Keys.SHIFT).perform();
    //等待5秒
      sleep(5);


}

}

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容