|
- import org.openqa.selenium.By;
- import org.openqa.selenium.WebDriver;
- import org.openqa.selenium.firefox.FirefoxDriver;
-
- public class FirstExample {
-
- public static void main(String[] args) throws Exception {
- WebDriver driver = new FirefoxDriver();
- driver.get("http://192.168.2.39/qlikview/index.htm");
- Thread.sleep(2000);
- driver.findElement(By.id("userName")).clear();
- driver.findElement(By.id("userName")).sendKeys("test");
- driver.findElement(By.id("pass")).clear();
- driver.findElement(By.id("pass")).sendKeys("test");
- driver.findElement(By.className("loginSubmit")).click();
- driver.get("http://192.168.2.39/QvAJAXZfc/opendoc.htm?document=QlikSales%20Fashion%20Phase%202%201104.qvw&host=QVS@view");
- driver.switchTo().frame("popupFrame1");
- driver.findElement(By.tagName("userid")).sendKeys("admin");
- driver.findElement(By.tagName("password")).sendKeys("admin");
- driver.switchTo().defaultContent();
- driver.close();
- }
复制代码 出错如下:Exception in thread "main" org.openqa.selenium.UnhandledAlertException: Modal dialog present: Login Failed
Build info: version: '2.41.0', revision: '3192d8a', time: '2014-03-27 17:18:15'
System info: host: 'yangxi', ip: '192.168.0.116', os.name: 'Windows 8', os.arch: 'amd64', os.version: '6.2', java.version: '1.6.0_43'
Session ID: 5af9ca81-bcd3-4501-9262-588c6649a00d
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{platform=XP, acceptSslCerts=true, javascriptEnabled=true, browserName=firefox, rotatable=false, locationContextEnabled=true, version=29.0.1, cssSelectorsEnabled=true, databaseEnabled=true, handlesAlerts=true, browserConnectionEnabled=true, nativeEvents=false, webStorageEnabled=true, applicationCacheEnabled=true, takesScreenshot=true}]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:193)
at org.openqa.selenium.remote.ErrorHandler.createUnhandledAlertException(ErrorHandler.java:174)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:141)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:595)
at org.openqa.selenium.remote.RemoteWebDriver$RemoteTargetLocator.frame(RemoteWebDriver.java:862)
at FirstExample.main(FirstExample.java:19)
登陆的用户名密码都没有错误啊,手动输入没问题,但是自动化输入就是没办法实现。求指教。 |
|