已打开,并填写了用户名和密码之类的字段,但未单击登录按钮。我无法找出问题所在。
System.setProperty("webdriver.ie.driver",AbsoluteDriverPath);
webdriver=new InternetExplorerDriver();
webdriver.get(URL);
webdriver.manage().window().maximize();
webdriver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
webdriver.findElement(By.id("Text1")).sendKeys(user);
webdriver.findElement(By.id("Password")).sendKeys(password);
webdriver.findElement(By.id("ButtonLogin")).click();
答案 0 :(得分:0)
请尝试以下代码:
System.setProperty("webdriver.ie.driver",AbsoluteDriverPath);
webdriver=new InternetExplorerDriver();
webdriver.get(URL);
webdriver.manage().window().maximize();
webdriver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
webdriver.findElement(By.id("Text1")).sendKeys(user);
webdriver.findElement(By.id("Password")).sendKeys(password);
try{
if (webdriver.findElement(By.id("ButtonLogin")).isDisplayed())
{
webdriver.findElement(By.id("ButtonLogin")).submit();
}
else{
System.out.println("Submit button is not display");
}
}
catch(Exception e){
System.out.println(e);
}
答案 1 :(得分:0)
使用点击方法->
webdriver.findElement(By.id("ButtonLogin")).click();