Firefox版本46。 Selenium版本:2.53.0 Eclipse中的代码: 包eezar_test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class test_sample {
public static void main(String[] args) {
WebDriver driver = new FirefoxDriver();
driver.get("www.gmail.com");
}
}
Eclipse中生成的错误:
线程中的异常" main" org.openqa.selenium.WebDriverException: 目标网址www.gmail.com格式不正确。命令持续时间或 超时:620毫秒构建信息:版本:' 2.53.0',修订版: ' 35ae25b',时间:' 2016-03-15 16:57:40'系统信息:主持人:' admin-PC', ip:' 192.168.0.102',os.name:' Windows 7',os.arch:' amd64', os.version:' 6.1',java.version:' 1.8.0_91'司机信息: org.openqa.selenium.firefox.FirefoxDriver功能 [{applicationCacheEnabled = true,rotate = false,handlesAlerts = true, databaseEnabled = true,version = 46.0.1,platform = WINDOWS, nativeEvents = false,acceptSslCerts = true,webStorageEnabled = true, locationContextEnabled = true,browserName = firefox, takesScreenshot = true,javascriptEnabled = true, cssSelectorsEnabled = true}]会话ID: 14d90792-c7c9-4828-a2d2-0de6707c86c5 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(本机方法) at sun.reflect.NativeConstructorAccessorImpl.newInstance(未知 来源)at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(未知 来自java.lang.reflect.Constructor.newInstance(未知来源) 在 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:678) 在 org.openqa.selenium.remote.RemoteWebDriver.get(RemoteWebDriver.java:316) 在eezar_test.test_sample.main(test_sample.java:15)引起: org.openqa.selenium.WebDriverException:目标网址www.gmail.com是 没有良好的形式。构建信息:版本:' 2.53.0',修订版:' 35ae25b', 时间:' 2016-03-15 16:57:40'系统信息:主持人:' admin-PC',ip: ' 192.168.0.102',os.name:' Windows 7',os.arch:' amd64',os.version: ' 6.1',java.version:' 1.8.0_91'驱动程序信息:driver.version:未知 at .FirefoxDriver.prototype.get(file:/// C:/Users/Monojit/AppData/Local/Temp/anonymous3216851504162366486webdriver-profile/extensions/fxdriver@googlecode.com/components/driver-component.js:10636) at .DelayedCommand.prototype.executeInternal_ / h(file:/// C:/Users/Monojit/AppData/Local/Temp/anonymous3216851504162366486webdriver-profile/extensions/fxdriver@googlecode.com/components/command-processor.js:12661) at .DelayedCommand.prototype.executeInternal_(file:/// C:/Users/Monojit/AppData/Local/Temp/anonymous3216851504162366486webdriver-profile/extensions/fxdriver@googlecode.com/components/command-processor.js:12666) at .DelayedCommand.prototype.execute /<(file:/// C:/Users/Monojit/AppData/Local/Temp/anonymous3216851504162366486webdriver-profile/extensions/fxdriver@googlecode.com/components/command-processor.js:12608 )
答案 0 :(得分:6)
您需要将协议添加到get方法中。
driver.get("http://gmail.com");