know-nada know-nada - 18 days ago 9x
Java Question

Selenium driver - windowhandle messes up

I'm using Selenium WebDriver on Firefox version 48.x.x. For this to work I need to use GeckoDriver/Marionette driver in order to talk to Firefox driver. In the older versions of Firefox, Selenium driver is able to get the session ID of a browser window using

however in the new(?) Gecko/Marionette driver, this function returns a short integer, not a long text string of hexadecimal. Is this a bug? or the new feature of Gecko/Marionette driver?

Here is where i ran into trouble:

1 - I start Firefox browser using Gecko/Marionette driver

final File file = new File("/Applications/geckodriver");
System.setProperty("webdriver.gecko.driver", file.getAbsolutePath());
driver = new FirefoxDriver();

It works fine. Then I print out the value of the browser window session ID:

System.out.println("WindowHandle ID = " + driver.getWindowHandle());

It shows some short integers somewhere between 10 to 20 which are incorrect.

Then I print out the browser session and I am able to see the actual session ID (the MAC field between the () ):

Brwowser Session = BrowserSession [driver=FirefoxDriver: Firefox on MAC (**bc4eb9db-608b-5643-8ec9-136b6c54f6a2**), user=Admin, lastPage=null]

Now I think the new Gecko/Marionette messed up the
function ? Because of this show-stopper, I am not able to switch the Selenium control from one window to another window or a pop-up.


Is there anyway that I can get the actual browser window session ID? Please help. I really need to get over this huge hurdle. I've been searching for a solution but found none.

I'm writing in Java.

Thanks a lot folks.


Use Selenium 2.53.1 + Firefox (v 48) with the following code

System.setProperty("webdriver.firefox.marionette", file.getAbsolutePath());


System.setProperty("webdriver.gecko.driver", file.getAbsolutePath());