运行Selenium时遇到麻烦

时间:2013-05-06 03:52:46

标签: java selenium eclipse-plugin webdriver

我在eclipse中写了一个简单的程序,当我运行它时会显示以下错误。我已经将selenium包添加到我的项目中

我的日食计划:

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class Gmail {

    /**
     * @param args
     */
    public static void main(String[] args) {    
        WebDriver wd1 = new FirefoxDriver();
        wd1.get("www.gmail.com");
    }
}

结果:

线程“main”中的异常

org.openqa.selenium.WebDriverException: Component returned failure code: 0x804b000a (NS_ERROR_MALFORMED_URI) [nsIIOService.newURI]
Command duration or timeout: 14 milliseconds
Build info: version: '2.32.0', revision: '6c40c18', time: '2013-04-09 17:23:22'
System info: os.name: 'Linux', os.arch: 'i386', os.version: '3.2.0-40-generic-pae', java.version: '1.7.0_21'
Session ID: 6c6bc33a-3296-4b06-b74d-53919dc5d6c9
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{platform=LINUX, databaseEnabled=true, cssSelectorsEnabled=true, javascriptEnabled=true, acceptSslCerts=true, handlesAlerts=true, browserName=firefox, browserConnectionEnabled=true, nativeEvents=false, webStorageEnabled=true, rotatable=false, locationContextEnabled=true, applicationCacheEnabled=true, takesScreenshot=true, version=20.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:525)
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:187)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:554)
    at org.openqa.selenium.remote.RemoteWebDriver.get(RemoteWebDriver.java:276)
    at Gmail.main(Gmail.java:13)
Caused by: org.openqa.selenium.remote.ErrorHandler$UnknownServerException: Component returned failure code: 0x804b000a (NS_ERROR_MALFORMED_URI) [nsIIOService.newURI]
Build info: version: '2.32.0', revision: '6c40c18', time: '2013-04-09 17:23:22'
System info: os.name: 'Linux', os.arch: 'i386', os.version: '3.2.0-40-generic-pae', java.version: '1.7.0_21'
Driver info: driver.version: unknown

1 个答案:

答案 0 :(得分:4)

您需要在网址中添加http://

public class Gmail {

    public static void main(String[] args) {
        WebDriver wd1 = new FirefoxDriver();
        wd1.get("http://www.gmail.com");
    }
}