Selenium 2 webdriver - 连接到 http://localhost:7055 被拒绝
我正在尝试使用selenium-java:2.2.0
,但我不断收到此错误:
org.openqa.selenium.WebDriverException: org.apache.http.conn.HttpHostConnectException: Connection to http://localhost:7055 refused
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '2.6.18-238.12.1.el5', java.version: '1.6.0_26'
Driver info: driver.version: FirefoxDriver
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:406)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:103)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:86)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:121)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:77)
at com.lexmark.cloudprint.BaseSeleneseTestCase.setUp(BaseSeleneseTestCase.groovy:21)
通过这个简单的设置:
class BaseSeleneseTestCase {
Selenium selenium
FirefoxDriver driver
@Rule public TestName name = new TestName();
@Before
public void setUp() {
driver = new FirefoxDriver();
def config = new ConfigSlurper(GrailsUtil.environment).parse(new File('grails-app/conf/Config.groovy').toURL())
selenium = new WebDriverBackedSelenium(driver, (String) config.grails.serverURL);
def GLOBAL_TIMEOUT_IN_MS = "10000"
selenium.setTimeout(GLOBAL_TIMEOUT_IN_MS)
}
在互联网上浏览,似乎很多人都遇到了同样的问题,但是我需要一些解决办法。有人让 selenium2 webdriver 在 Linux 上工作吗?如果是这样,怎么办?
I'm trying to use selenium-java:2.2.0
, and I keep getting this error:
org.openqa.selenium.WebDriverException: org.apache.http.conn.HttpHostConnectException: Connection to http://localhost:7055 refused
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '2.6.18-238.12.1.el5', java.version: '1.6.0_26'
Driver info: driver.version: FirefoxDriver
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:406)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:103)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:86)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:121)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:77)
at com.lexmark.cloudprint.BaseSeleneseTestCase.setUp(BaseSeleneseTestCase.groovy:21)
With this simple setup:
class BaseSeleneseTestCase {
Selenium selenium
FirefoxDriver driver
@Rule public TestName name = new TestName();
@Before
public void setUp() {
driver = new FirefoxDriver();
def config = new ConfigSlurper(GrailsUtil.environment).parse(new File('grails-app/conf/Config.groovy').toURL())
selenium = new WebDriverBackedSelenium(driver, (String) config.grails.serverURL);
def GLOBAL_TIMEOUT_IN_MS = "10000"
selenium.setTimeout(GLOBAL_TIMEOUT_IN_MS)
}
Poking around the internet, it seems like many people are having the same issue, but I need some kind of work around. Has anyone gotten selenium2 webdriver to work on linux? If so, how?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 WebDriverBackedSelenium 意味着您要求连接到远程控制的驱动程序。如果这就是你想要的,我认为你必须部署远程控制的 selenium 服务器。
如果您只想直接在 Firefox 中执行测试(我的意思是,没有 RemoteControl Selenium),您可以完全避免使用 WebDriverBackedSelenium,如下所示:
阅读测试的其余部分将有助于更好地理解您的问题:如何调用测试方法、断言等。
更新 可以使用基本的 WebDriver 接口在实现之间进行切换(例如,更改浏览器)。
像这样的事情:
在基本测试类中:
为每个浏览器扩展这个类来测试:
这是您需要的吗?
Using WebDriverBackedSelenium means you're asking to connect to a remote-controlled Driver. If that is what you wants, I think you have to deploy the remote controlled selenium server.
If you only want to execute your tests directly in Firefox (I mean, no RemoteControl Selenium), you can avoid using WebDriverBackedSelenium at all, with something like this:
It would be useful to better understand your problem to read the rest of your test: how do you call test methods, assertions and so on.
UPDATE It's possible to use the base WebDriver interface in order to switch between implementations (to change browser, for example).
Something like this:
in base test class:
Extend this class for every browser to test:
Is this what you needed?
请检查您的 Firefox 版本,也许新的 Firefox 需要更高的 Selenium 驱动程序。
目前我必须升级到 Firefox 29.0 的 selenium 驱动程序 2.39.0。
Please check the version of your firefox, maybe a new firefox need a higher selenium driver.
At the moment i must upgrade to selenium driver 2.39.0 for firefox 29.0.