***更新相关的HTML代码的问题。
我面对错误,而试图从下拉式的任意值。
错误的是
异常在线程“主要” org.openqa.selenium.NoSuchElementException:不能找到用CSS选择器单元== #oHeight
在提到我已经将所有的IE设置硒文档
我曾尝试代码提到如下:
System.setProperty("webdriver.ie.driver", "D:\\Workspace\\Selenium\\Model\\servers\\IEDriverServer_32bit.exe");
WebDriver driver = new InternetExplorerDriver();
driver.manage().timeouts().implicitlyWait(15000, TimeUnit.MILLISECONDS);
driver.get("http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/showModalDialog2.htm");
WebElement ddlHeight = driver.findElement(By.id("oHeight"));
Select select = new Select(ddlHeight);
select.selectByVisibleText("150");
driver.findElement(By.xpath("//input[@value='Push To Create']")).click();
driver.quit();
该系统配置是视窗7 + IE 11
你可以试试这个代码,它的工作对我的系统:我使用的是IE 11 + Win7专业版:
码
public class Sandeep {
static WebDriver driver;
static WebDriverWait wait;
public static void main(String[] args) throws InterruptedException {
System.setProperty("webdriver.ie.driver", "D:\\Automation\\IEDriverServer.exe");
InternetExplorerOptions options = new InternetExplorerOptions();
options.ignoreZoomSettings();
driver = new InternetExplorerDriver(options);
driver.manage().window().maximize();
wait = new WebDriverWait(driver, 40);
driver.get("http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/showModalDialog2.htm");
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("oHeight")));
wait.until(ExpectedConditions.elementToBeClickable(By.id("oHeight")));
Select select = new Select(driver.findElement(By.id("oHeight")));
select.selectByVisibleText("150");
// wait.until(ExpectedConditions.elementToBeClickable(By.name("Push To Create")));
// driver.findElement(By.name("Push To Create")).click();
driver.close();
}
}
请让我知道,如果您有与此相关的任何问题。