3

I need to implement switch from one window to another in IE. However, element driver doesn't support getWindowHandle function.

I assume it might be just configuration problem or settings, though I don't know how to fix it.

Please, any suggestions.

I'm working with c# - Visual Studio

u_untouchable
  • 129
  • 1
  • 3
  • 11
  • 2
    What version of webdriver? IE? What do u mean by doesn't support? – niharika_neo Apr 02 '13 at 06:31
  • I use IE8, webdriver version 2.31.0.0 I initializaed driver in SetUp() by this way: IWebDriver driver = new InternetExplorerDriver(); However, when I'm trying to call getWindowHandle() from driver instance, I don't see getWindowHandle() function in the list. – u_untouchable Apr 02 '13 at 10:19

2 Answers2

4

You haven't said which language bindings you're using, but based on a comment you posted, it looks like you're using C#. The method names are slightly different for each language binding. From this answer:

The object, method, and property names in the .NET language bindings do not exactly correspond to those in the Java bindings. One of the principles of the project is that each language binding should "feel natural" to those comfortable coding in that language.

So you have to do a little translation if you're trying to copy-paste Java code. In this case, you want the combination of the WindowHandles property (to look for the new window handle) and the CurrentWindowHandle property of the driver. You can find full API documentation for the .NET bindings at the project's Google code site.

Community
  • 1
  • 1
JimEvans
  • 27,201
  • 7
  • 83
  • 108
1

I am going to make wild guess:

Try to initialize your driver like this:

 WebDriver driver = new FirefoxDriver(); //assume you use firefox

The interface WebDriver supports that method. Do not forget to store the handle somewhere ;)

String myWindow = driver.getWindowHandle();

BTW that method should return you actual window If you need all windows you probably should use getWindowHandles() method

If this does not work, please provide more info:

  • what error exactly are you getting?
  • How do you initialize WebDriver?
  • What version of selenium are you using?|
  • What type of driver are you using?
Pavel Janicek
  • 14,128
  • 14
  • 53
  • 77