导入java.util.concurrent.TimeUnit;
导入org.openqa.selenium.By;
导入org.openqa.selenium.WebDriver;
导入org.openqa.selenium.WebElement;
导入org.openqa.selenium.chrome.ChromeDriver;
///导入org.openqa.selenium.interactions.Actions;
导入org.openqa.selenium.support.ui.ExpectedConditions;
导入org.openqa.selenium.support.ui.WebDriverWait;
公共类测试用例{
public static void main(String [] args){
// TODO Auto-generated method stub
WebDriver driver=null;
driver = new ChromeDriver();
System.setProperty("webdriver.chrome.driver", "C:\\selenium workspace\\SeleniumProject\\Drivers\\chromedriver.exe");
String browserID=driver.getWindowHandle();
System.out.println(browserID);
driver.get("https://filesamples.com/formats/pdf");
driver.manage().window().maximize();
driver.manage().deleteAllCookies();
//Actions act=new Actions(driver);
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
///新的WebDriverWait(driver,20).until(ExpectedConditions.elementToBeClickable(By.cssSelector(“#output> div:nth-child(1)> a”))))。click();
// act.moveToElement(driver.findElement(By.xpath(“ // * [@ id =” output“] / div [1] / a”)))。click()。perform(); < / p>
// driver.manage()。timeouts()。implicitlyWait(10,TimeUnit.SECONDS);
WebElement download=driver.findElement(By.cssSelector("#output > div:nth-child(1) > a"));
//driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
download.click();
}
}