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();
} }