Webdriver执行不起作用(Webdriverexception)

时间:2015-11-17 03:26:46

标签: selenium-webdriver automation automated-tests testng

我写了一个非常基本的脚本来登录应用程序并注销。该脚本一登录到应用程序就停止工作并发出异常,我无法弄清楚原因。这是剧本。

public class Login {

WebDriver driver = new FirefoxDriver();
String url = "http://xxxxxxxxx";

@Test
public void login_class() {

    driver.get(url + "/Web/guest/login.aspx");
    driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
    driver.findElement(By.id("txtUserName")).clear();
    driver.findElement(By.id("txtUserName")).sendKeys("xxxxx@gmc.com");
    driver.findElement(By.id("txtPassword")).clear();
    driver.findElement(By.id("txtPassword")).sendKeys("xxxxx123");
    driver.findElement(By.id("btnLogin")).click();
    driver.get(url + "Web/guest/home/default.aspx");
    driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
    driver.findElement(
            By.cssSelector("span.menu-icons-sprite.menu-icon-signout"))
            .click();

}

@BeforeTest
public void create_driver() {

    driver.get(url);
    driver.manage().window().maximize();

}

@AfterTest
public void exit() {

    driver.quit();
}

}

遵循给出的例外情况

失败:login_class org.openqa.selenium.WebDriverException:f.QueryInterface不是函数 命令持续时间或超时:5.10秒 构建信息:版本:'2.48.2',修订版:'41bccdd',时间:'2015-10-09 19:55:52' 系统信息:主机:'xxxxx-PC',ip:'10 .0.0.192',os.name:'Windows 7',os.arch:'amd64',os.version:'6.1',java.version:'1.7 .0_45' 会话ID:1e311cd0-34d1-4dd2-9cde-e52cbb9fb52e 驱动程序信息:org.openqa.selenium.firefox.FirefoxDriver Capabilities [{platform = WINDOWS,acceptSslCerts = true,javascriptEnabled = true,cssSelectorsEnabled = true,databaseEnabled = true,browserName = firefox,handlesAlerts = true,nativeEvents = false,webStorageEnabled = true,rotating = false,locationContextEnabled = true,applicationCacheEnabled = true ,takeScreenshot = true,版本= 42.0}]     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)     at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)     at java.lang.reflect.Constructor.newInstance(Constructor.java:526)     在org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)     在org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)     在org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:647)     在org.openqa.selenium.remote.RemoteWebDriver.get(RemoteWebDriver.java:311)     在bileetaTest.Login.login_class(Login.java:27)     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)     at java.lang.reflect.Method.invoke(Method.java:606)     at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)     at org.testng.internal.Invoker.invokeMethod(Invoker.java:639)     在org.testng.internal.Invoker.invokeTestMethod(Invoker.java:816)     at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1124)     at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)     at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108)     在org.testng.TestRunner.privateRun(TestRunner.java:774)     在org.testng.TestRunner.run(TestRunner.java:624)     在org.testng.SuiteRunner.runTest(SuiteRunner.java:359)     在org.testng.SuiteRunner.run顺序(SuiteRunner.java:354)     在org.testng.SuiteRunner.privateRun(SuiteRunner.java:312)     在org.testng.SuiteRunner.run(SuiteRunner.java:261)     在org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)     在org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)     at org.testng.TestNG.runSuitesSequentially(TestNG.java:1215)     在org.testng.TestNG.runSuitesLocally(TestNG.java:1140)     在org.testng.TestNG.run(TestNG.java:1048)     at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:112)     在org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:205)     在org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:176) 引起:org.openqa.selenium.WebDriverException:f.QueryInterface不是函数 构建信息:版本:'2.48.2',修订版:'41bccdd',时间:'2015-10-09 19:55:52' 系统信息:主机:'xxxx-PC',ip:'xxxxxxx',os.name:'Windows 7',os.arch:'amd64',os.version:'6.1',java.version:'1.7.0_45 “ 驱动程序信息:driver.version:未知     at .FirefoxDriver.prototype.get(file:/// C:/Users/xxxxxx/AppData/Local/Temp/anonymous3548365288572112291webdriver-profile/extensions/fxdriver@googlecode.com/components/driver-component.js:10523)

===============================================     默认测试

测试运行:1,失败:1,跳过:0

1 个答案:

答案 0 :(得分:0)

问题是我必须添加另一个" /"在我提供的路径之前。