0

I am working with an older version of an automation script that logs into a page and runs tests.

We want to change the classic selenium constructor to a WebDriverBackedSelenium constructor in order to do some more involved testing.

Our original constructor call was:

selenium = new DefaultSelenium("localhost", 4444, "*firefox", "https://asdffdsa.com/");

How do I set the WebDriverBackedSelenium constructor with the same parameters? The API shows that we need to set the constructor as:

seWebDriver = new WebDriverBackedSelenium(driver, "https://asdffdsa.com");

There doesn't seem to be any indication about where the selenium server is running, what port, and what browser.

Currently using the following code:

driver = new FirefoxDriver();
    seWebDriver = new WebDriverBackedSelenium(driver, "https://www.asdfdfdfsfs.com");

    seWebDriver.open("/");

Just now noticing that I'm getting the following error:

Caused by: org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output: * LOG addons.manager: Application has been upgraded LOG addons.xpi: startup LOG addons.xpi: Skipping unavailable install location app-system-share LOG addons.xpi: Ignoring file entry whose name is not a valid add-on ID: /var/folders/pf/hvzyf38x59vfbgf8zpvw5v800000gn/T/anonymous2501560210712840923webdriver-profile/extensions/webdriver-staging LOG addons.xpi: checkForChanges LOG addons.xpi-utils: Opening database LOG addons.xpi-utils: Creating database schema LOG addons.xpi: New add-on fxdriver@googlecode.com installed in app-profile Blocklist::_loadBlocklistFromFile: blocklist is disabled LOG addons.xpi: New add-on {972ce4c6-7e08-4474-a285-3208198ce6fd} installed in app-global LOG addons.xpi: Updating database with changes to installed add-ons LOG addons.xpi-utils: Updating add-on states LOG addons.xpi-utils: Writing add-ons list LOG addons.manager: shutdown LOG addons.xpi: shutdown LOG addons.xpi-utils: shutdown LOG addons.xpi-utils: Database closed LOG addons.xpi: startup LOG addons.xpi: Skipping unavailable install location app-system-share LOG addons.xpi: Ignoring file entry whose name is not a valid add-on ID: /var/folders/pf/hvzyf38x59vfbgf8zpvw5v800000gn/T/anonymous2501560210712840923webdriver-profile/extensions/webdriver-staging LOG addons.xpi: checkForChanges * LOG addons.xpi: No changes found

Sakamoto Kazuma
  • 2,573
  • 7
  • 34
  • 75
  • dude, look at my answer below. instead of using driver = new FirefoxDriver() use a driver = new RemoteWebDriver(hub, capabilities) where hub is something like http://localhost:4444/wd/hub. I don't understand why you'd edit the question when I already provided the answer. Also, the selenium documentation is pretty good, all of this stuff is answered there. – KyleM Mar 07 '13 at 21:37
  • The error that I was getting as listed above was due to versioning incomaptibilities or something. Please see http://stackoverflow.com/questions/10013898/unable-to-connect-to-host-127-0-0-1-on-port-7055 for more information on that. – Sakamoto Kazuma Mar 08 '13 at 18:54

2 Answers2

1

Here is an example for using Webdriver backed selenium.

There will be no need to mention the port number while using webdriverbacked Selenium.

In the below program, the object Selenium is for utilising the properties of Selenium RC(your old automation script constructor).

The object driver is for utilising the features of Webdriver (Selenium2.0).

public class BackedWebdriver {

    public static WebDriver driver;
    public static String baseUrl;
    public static Selenium selenium;

    public static void main(String[] args) {
        driver = new FirefoxDriver();    //Here we are mentioning that we will use Firefox browser
        baseUrl = "http://www.google.co.in/";
        driver.get(baseUrl);
        selenium = new WebDriverBackedSelenium(driver, baseUrl);
        selenium.windowMaximize();
        driver.findElement(By.id("gbqfq")).clear();
        driver.findElement(By.id("gbqfq")).sendKeys("selenium");
        selenium.click("g");
        driver.findElement(By.id("gbqfb")).click();


    }
HemChe
  • 2,249
  • 1
  • 21
  • 33
  • I think we need the features of Webdriver in this automation, but when I set this up and run it as a UnitTest, it's trying to load localhost instead of the site that I gave it in the constructor. – Sakamoto Kazuma Mar 06 '13 at 21:25
  • Are you using driver.get(url) or selenium.open(url) ? It would be helpful if you can share the code. – HemChe Mar 07 '13 at 05:06
  • selenium.open(url) code is a mess I'mma try to clean it up a bit and post the relevant parts up. – Sakamoto Kazuma Mar 07 '13 at 19:06
0
DesiredCapabilities ffLinux = DesiredCapabilities.firefox();
ffLinux.setBrowserName("firefox");
ffLinux.setPlatform(Platform.LINUX);
String hubLocation = http://yourmachine.com:4444/wd/hub;
WebDriver driver = new RemoteWebDriver(hubLocation, ffLinux);
driver.get(yourWebApplicationURLThatsBeingTested);

In your example above with the WebDriverBackedSelenium, the first parameter you passed in was "driver". Look at how I set up my WebDriver above: it specifies the hub location.

KyleM
  • 4,445
  • 9
  • 46
  • 78