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);
}
}
网友评论