2018-11-13

java (js代码)


var xpath = "//input[@type='date']";var element = document.evaluate(xpath,document,null,XPathResult.ANY_TYPE,null).iterateNext();element.value="2018-12-13";改时间2018-12-13

String js = "var xpath = "//input[@type='date']";var element = document.evaluate(xpath,document,null,XPathResult.ANY_TYPE,null).iterateNext();element.value="2018-12-13";";

JavascriptExecutor jsDriver = (JavascriptExecutor)driver;

jsDriver.executeScript(js);

[图片上传失败...(image-50eb97-1544701273336)]

修改时间 java代码(date-2018-12-20);

(文本,文件,数字,密码文本框代码)(淘宝搜索框-搜手机)

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("手机");
sleep(2);

(淘宝按钮,找到搜索按钮代码)
@Test
public void testbutton() {
testTextInput();
WebElement button = driver .findElement(By.xpath("//button[contains(text(),'搜索')]"));
button.click();
sleep(2);
}

(淘宝文本框,搜索箱包)

public void TestTextInput() {
driver.get("https://www.taobao.com/");
WebElement text = driver.findElement(By.xpath("//input[@id='q']"));
text.clear();
text.sendKeys("箱包");
sleep(2);

(淘宝超链接搜鲜花)

[图片上传失败...(image-78013-1544701273335)]

(下拉框多选框测试-查找橘子和香蕉)

@Test public void testSelect(){
driver.get("file://C:\Users\Administrator\Documents\WeChat Files\SL18551185539\Files\demo.html");
WebElement select = driver.findElement(By.xpath("//select"));
Select selects = new Select(select);
selects.selectByVisibleText("香蕉");
sleep(3);
selects,selectBy index(0);
sleep(2);
selects,select Byvalue("橘子")
sleep(3);

(页面元素改日期)

public void testDate() {
driver.get(
"file://C:\Users\Administrator\Documents\WeChat Files\SL18551185539\Files\demo.html");
WebElement date = driver.findElement(By.xpath("//input[@type='date']"));
//date.clear();
date.sendKeys("2018-12-13");
String js = "var xpath = "//input[@type='date']";
JavascriptExecutor jsDriver = (JavascriptExecutor) driver
jsDriver.executeScript(js);
sleep(2);

[图片上传失败...(image-d48b54-1544701273333)]

 (淘宝,京东,百度同时跳转搜索) 

@Test
public void testNavigate(){
driver.get("https://www.baidu.com/");
sleep(1);
driver.get("https://www.jd.com/");
sleep(1);
driver.navigate().back();
sleep(1);
driver.navigate().forward();
sleep(1);
driver.navigate().refresh();
sleep(1);
driver.get("https://www.taobao.com/");
sleep(1);
}

你可能感兴趣的:(2018-11-13)