WebDriver高级应用实例(2)

  2.1在日期选择器上进行日期选择

  被测网页的网址:

  https://www.html5tricks.com/demo/Kalendae/index.html

  Java语言版本的API实例代码

import org.testng.annotations.Test;
import org.testng.annotations.BeforeMethod;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.AfterMethod; public class testdata {
WebDriver driver;
String url = "https://www.html5tricks.com/demo/Kalendae/index.html";
@Test
public void testdataPicker()throws Exception {
WebElement dataInputBox = driver.findElement(By.id("input1"));
dataInputBox.clear();
dataInputBox.sendKeys("3/20/2019");
}
@BeforeMethod
public void beforeMethod() {
System.setProperty("webdriver.chrome.driver", "D:\\WebDriver\\chromedriver_win32\\chromedriver.exe");
driver = new ChromeDriver();
driver.manage().window().maximize();
driver.get(url);
} @AfterMethod
public void afterMethod() {
driver.quit();
} }
上一篇:浅谈测试驱动开发(TDD)


下一篇:【记】研究Sharding-JDBC遇到的一个异常(Caused by: io.shardingsphere.core.exception.ShardingException: Cannot get uniformed table structure for `t`. The different meta data of actual tables are as follows)