Reputation: 67832
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?
Upvotes: 3
Views: 3307
Reputation: 765
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.
Upvotes: 0
Reputation: 691
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:
FirefoxDriver driver;
driver = new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
[...]
driver.get(myTestUrl);
driver.findElement(By.xpath(myElementXpath)).click();
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:
public abstract class WebDriverBaseTest {
protected WebDriver driver;
@Before
public void setUp() throws Exception {
setDriverForTest();
}
protected abstract void setDriverForTest();
// Rest of tests here ...
}
Extend this class for every browser to test:
public class FirefoxTest extends WebDriverBaseTest {
@Override
protected void setDriverForTest() {
driver = new FirefoxDriver();
}
}
public class HtmlUnitTest extends WebDriverBaseTest {
@Override
protected void setDriverForTest() {
HtmlUnitDriver htmlUnitDriver = new HtmlUnitDriver(BrowserVersion.FIREFOX_3_6);
htmlUnitDriver.setJavascriptEnabled(true);
driver = htmlUnitDriver;
}
}
Is this what you needed?
Upvotes: 1