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

2
  • 2
    What version of webdriver? IE? What do u mean by doesn't support? Commented Apr 2, 2013 at 6: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. Commented Apr 2, 2013 at 10:19

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

3 Comments

JimEvansm, thanks a lot! It seems you are right. I'll try to handle it with WindowHandles and CurrentWindowHandle
It would be great if you could mark this answer as the proper one.
JimEvans, can I use similar approach? stackoverflow.com/questions/11237357/…
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?

3 Comments

Unfortunately, this way doesn't work as well. If I initialize webdriver to work with FF it still doesn't provide function I need.
See JimEvans response - and btw next time it is better to say which language are you using, so that I dont have to make such wild guesses
Ok,sure, I'll do it.Thanks anyway!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.