driver.findElement(By.cssSelector("#ucWareHouseTwoLevel_ddlWarehouse_chosen")).click();//选择下拉框(出现下拉框的选项)
driver.findElement(By.cssSelector(".active-result[data-option-array-index="3"]")).click();//点击选择值
new Select(driver.findElement(By.id("ucUserBizType_ddlUserBizType"))).selectByVisibleText("P2B");
driver.findElement(By.cssSelector("option[value="1"]")).click();//也是下拉选择
String currenthandle = driver.getWindowHandle();
Set<String> handles = driver.getWindowHandles();
for (String handle : handles) {
driver.switchTo().window(handle);
if (driver.getPageSource().contains("商品")) {
driver.switchTo().window(handle);
driver.findElement(By.id("productName")).clear();
driver.findElement(By.id("productName")).sendKeys("new1");
driver.findElement(By.id("btnSearch")).click();
driver.findElement(By.linkText("new1")).click();
break;
}
}//切换窗口
driver.switchTo().window(currenthandle);//切回窗口
driver.findElement(By.id("txtArrivalTime")).sendKeys("2017-05-27");//时间控件,选择时间,(readonly,又没iframe id那就有点坑了)
assertTrue(closeAlertAndGetItsText().contains("确定退出吗"))//断言