How to control browser in focus?
I'm playing around with C# webdriver and trying to figure out how to control which browser is in focus.
This is basicly what i want do
driver = StartBrowser();
driver1 = StartBrowser();
and then switch back to driver, but i can开发者_如何学Python't get it working.
I know it's prob really simple but i still can't get it working :).
This is what i tried different versions of:
driver.SwitchTo().Window(driver.CurrentWindowHandle);
SwitchTo
is to change the context of a single driver (browser). This is used when you have frames or pop up windows and you want to tell selenium where to look for elements.
If you declare two separate driver instances (per your example) then you will have two independent browser instances where each will have its own context to search. There is logically no reason to switch between them because you can search each browser by using the corresponding driver variable.
精彩评论