Selenium WebDriver gives the same window handle across multiple Firefox browser sessions
We use different profiles to test different features of our system. If we open new multiple FF sessions (each with it's own profile), Selenium Webdriver only uses 1 window handle identifier.
(pseudo code below)
WebDriver driver1 = new FirefoxDriver(Profile1); WebDriver driver2 = new FirefoxDriver(Profile2); WebDriver driver3 = new FirefoxDriver(Profile3); String h1 = driver1.getWindowHandle(); String h2 = driver3.getWindowHandle(); String h3 = driver3.getWindowHandle();
EVERY ONE of the window handles will be identical, even though these were new sessions with unique profiles. (That is, h1 == h2 == h3 )
Am I missing something here? I would have thought that the handles would be unique for each window?
It shouldn't happen given, at least I cannot reproduce your issue:
each time the handle represents an unique GUID structure.
Consider the following checklist:
- Make sure you use thread-safe collections, functions and patterns
- Avoid using static fields
- Implement thread-local storage pattern at least for WebDriver class instances
Check out Parallel Tests Execution article for more details and example sample project you can use as the reference.