Re: getWindowHandles() return only 1 window in IE

12,100 views
Skip to first unread message
Message has been deleted

darrell

unread,
Mar 29, 2012, 8:30:23 AM3/29/12
to webd...@googlegroups.com
Not really a lot to go on here. When you post a question, think of it like posting a defect report. The more information you can provide the more likely the problem will get resolved.

  • Which version of WebDriver?
  • Which version of IE?
  • Which version of Firefox or Chrome?
  • Which language are you programming in?
  • Do you have an example of the code which opens a window?
  • Please provide a list of steps to reproduce.
  • Have you looked at the differences in the web page, Firefox versus IE?
With the information you have provided the best you can hope for are wild guesses.


On Wednesday, 28 March 2012 13:11:54 UTC-4, Akshay Rudraksha wrote:


On Tue, Mar 27, 2012 at 11:55 AM, Akshay Rudraksha <aksh...@gmail.com> wrote:
I am stuck at place where IE unable to get details of new Popup window, i tried to using getWindowHandles() but it just return single window. It's not even wait issue as the window does get open in few sec (I did tried putting sleep)

With Firefox and Chrome i am able to get handle of new window...





--
--
Akshay Rudraksha






--
--
Akshay Rudraksha
Synechron Technologies Pvt. Ltd,
Wells Fargo Bank,San Francisco,CA
Cell - 1-925-353-8210



Santosh kumar

unread,
Mar 29, 2012, 10:04:26 AM3/29/12
to webd...@googlegroups.com
Try this,,

       // before clicking on the link
        String parent = driver.getWindowHandle();

       // after clicking on the link
        Thread.sleep(1000);
        Set<String> availableWindows = driver.getWindowHandles();
        String newWindow = null;
        for (String window : availableWindows) {
            if (!parent.equals(window)) {
                newWindow = window;
            }
        }
        assertNotNull(newWindow);

        // switch to new window
        driver.switchTo().window(newWindow);
        // do assert the elements in the new window
        // and then close the new window
        driver.close();
        // switch to parent
        driver.switchTo().window(parent);
        // close main window
        driver.close();

 hope it helps you :) cheers,,,


On Thu, Mar 29, 2012 at 7:17 PM, Akshay Rudraksha <aksh...@gmail.com> wrote:
Webdriver - 2.20 Latest selenium version
IE - IE8
FF and Chrome works fine - Chrome 17....FF- 11
Lang Used - Java
Steps to Reproduce - 
 -Enter Login Credential hit Sigon it provide you link to Application
- By hitting on any of the link will open new Window which is not being recognized.



Below is the code i used to Click on link - 



//Driver.driver.switchTo().window("Commercial Electronic Office");
String Login = Driver.driver.getWindowHandle();

Driver.driver.findElement(By.xpath("//a[contains(text(),'Exchange')]")).sendKeys(Keys.RETURN);
//Thread.sleep(10000);
for (String handle1 : Driver.driver.getWindowHandles()) { // This is where i am not getting any window, it just show default Login window...





--
You received this message because you are subscribed to the Google Groups "webdriver" group.
To view this discussion on the web visit https://groups.google.com/d/msg/webdriver/-/ozIY5vQ4KhsJ.
To post to this group, send email to webd...@googlegroups.com.
To unsubscribe from this group, send email to webdriver+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/webdriver?hl=en.



--
--
Akshay Rudraksha
Synechron Technologies Pvt. Ltd,
Wells Fargo Bank,San Francisco,CA
Cell - 1-925-353-8210



--
You received this message because you are subscribed to the Google Groups "webdriver" group.
To post to this group, send email to webd...@googlegroups.com.
To unsubscribe from this group, send email to webdriver+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/webdriver?hl=en.



--
Santosh Kumar K

darrell

unread,
Mar 30, 2012, 10:51:47 AM3/30/12
to webd...@googlegroups.com
This is better. Still missing a few things. When you created the automation, you had access to the HTML you were trying to automate. Not having the HTML means part of the conversation is missing for everyone reading this (except you).

The WebDriver Java code is curious. Things that immediately catch my eye:

  1. The findElement is using the XPath function contains(). This means it could potentially match more than one element. This could result in different behaviour on different browsers. Could even change when you update a browser which currently works.
  2. You are using sendKeys(Keys.RETURN) rather than click(). Using sendKeys this way would be equivalent to use the TAB key to get to the anchor then pressing RETURN. Does this actually open the window? If it does, could this be throwing off WebDriver?
These two points are pure speculation. Without the HTML code you are automating there still isn't enough information to know why this is different in Firefox/Chrome versus IE8. What does the anchor tag look like? Is there something tricky in the target attribute? Is there something unusual in the href attribute? Until we understand how the window gets opened it will be hard to figure out why WebDriver is not detecting the window opening and adding its handle to the list of open windows.

Darrell

On Thursday, 29 March 2012 09:47:06 UTC-4, Akshay Rudraksha wrote:
Webdriver - 2.20 Latest selenium version
IE - IE8
FF and Chrome works fine - Chrome 17....FF- 11
Lang Used - Java
Steps to Reproduce - 
 -Enter Login Credential hit Sigon it provide you link to Application
- By hitting on any of the link will open new Window which is not being recognized.



Below is the code i used to Click on link - 



//Driver.driver.switchTo().window("Commercial Electronic Office");
String Login = Driver.driver.getWindowHandle();

Driver.driver.findElement(By.xpath("//a[contains(text(),'Exchange')]")).sendKeys(Keys.RETURN);
//Thread.sleep(10000);
for (String handle1 : Driver.driver.getWindowHandles()) { // This is where i am not getting any window, it just show default Login window...

mukesh rawat

unread,
May 17, 2012, 6:33:47 AM5/17/12
to webd...@googlegroups.com

Hi Akshay,

I have also faced this problem. Solution for this is:-

 for ie use  driver.getWindowHandles() just before where u store the values of it in Set.
just like that,...as shown


  // before clicking on the link
        String parent = driver.getWindowHandle();

       // after clicking on the link
        Thread.sleep(1000);
        driver.getWindowHandles();

        Set<String> availableWindows = driver.getWindowHandles();
        String newWindow = null;
        for (String window : availableWindows) {
            if (!parent.equals(window)) {
                newWindow = window;
            }
        }

Thanks,
Mukesh
mraw...@gmail.com

Danny Guerrier

unread,
May 17, 2012, 8:04:26 AM5/17/12
to webd...@googlegroups.com
I more reliable way would be to call getWindowHandles before the click the spawns the new window then creat a wait the looks for a +1 increase in windows before continuing.  
--
You received this message because you are subscribed to the Google Groups "webdriver" group.
To view this discussion on the web visit https://groups.google.com/d/msg/webdriver/-/rxiBpERIY1YJ.

darrell

unread,
May 18, 2012, 9:02:38 AM5/18/12
to webdriver
Mukesh,

I have an application as follows:

- main window with a button to send an email
- email window with a TO field and a button to open a list of contacts
- contacts window

If I used your code to get the handle for the email window it would
work. Your logic is:

- Save the handle for the main window.
- Open the email window
- Scan the current window handles
- if the current window handle is not the main window assume it is
the email window

This works great if there are only two windows open. However, if I now
click the contact list button the logic becomes:

- Save the handle for the email window
- Open the contacts window
- Scan the current window handles
- if the current window handle is not the email window assume it
is the contacts window

The problem is that the current window MAY be the main window. A
better solution which works for 2 OR MORE windows would be:

public static String switchToPopupWindow(WebDriver driver, By by) {
Set<String> handles = driver.getWindowHandles();
int size = handles.size();
WebElement we = driver.findElement(by);
we.click();
Set<String> handles2 = null;
int size2;
do {
handles2 = driver.getWindowHandles();
size2 = handles2.size();
Thread.sleep(250);
} while(size2 - size != 1);
handles2.removeAll(handles);
String newWindowHandle = (String)handles2.toArray()[0];
return newWindowHandle;
}

The logic here is:

- Get a list of window handles
- Click the element which opens the new window
- Get a second list of window handles
- Subtract the first set from the second set

Whatever remains in the second set will be the handle for the new
window. To be safe I would also add a timeout to the while loop. That
is, if it never finds a new window handle, timeout in XXX number of
seconds.

Darrell

On May 17, 6:33 am, mukesh rawat <mrawat...@gmail.com> wrote:
> Hi Akshay,
>
> I have also faced this problem. Solution for this is:-
>
>  for ie use  driver.getWindowHandles() just before where u store the values
> of it in Set.
> just like that,...as shown
>
>   // before clicking on the link
>         String parent = driver.getWindowHandle();
>
>        // after clicking on the link
>         Thread.sleep(1000);
> *        driver.getWindowHandles();*
>         Set<String> availableWindows = driver.getWindowHandles();
>         String newWindow = null;
>         for (String window : availableWindows) {
>             if (!parent.equals(window)) {
>                 newWindow = window;
>             }
>         }
>
> Thanks,
> Mukesh
> mrawat...@gmail.com

mukesh rawat

unread,
May 21, 2012, 1:37:05 AM5/21/12
to webd...@googlegroups.com
Darell,

I have facing problem with IE modal Dialogs. Then i use window handles twice in my previous code(once before storing its value in Set).

driver.getWindowHandles();

Set<String> availableWindows = driver.getWindowHandles();


And your logic is perfect for more than one popup in same app. Thanks, for that.


Mukesh,

Deepak Goel

unread,
Aug 17, 2012, 3:02:13 AM8/17/12
to webd...@googlegroups.com
None of the solution provided is working for me. Always it returns 1

poseidon

unread,
Aug 21, 2012, 12:40:14 PM8/21/12
to webdriver
I had the same issue. If you are using Win7 with IE9 then
selenium2.25 should fix this issue.

It did not make sense why would it work fine in FFX and chrome then
not in IE. So check the IE version and the webdriver(selenium)
vesion.


On Aug 17, 3:02 am, Deepak Goel <deepak.pra...@gmail.com> wrote:
> None of the solution provided is working for me. Always it returns 1
>
>
>
> On Wednesday, 28 March 2012 22:41:54 UTC+5:30, Akshay Rudraksha wrote:
>
> > On Tue, Mar 27, 2012 at 11:55 AM, Akshay Rudraksha <aksh...@gmail.com<javascript:>
> > > wrote:
>
> >> I am stuck at place where IE unable to get details of new Popup window, i
> >> tried to using getWindowHandles() but it just return single window. It's
> >> not even wait issue as the window does get open in few sec (I did tried
> >> putting sleep)
>
> >> With Firefox and Chrome i am able to get handle of new window...
>
> >> --
> >> --
> >> Akshay Rudraksha
>
> > --
> > --
> > Akshay Rudraksha
> > Synechron Technologies Pvt. Ltd,
> > Wells Fargo Bank,San Francisco,CA
> > Cell - 1-925-353-8210- Hide quoted text -
>
> - Show quoted text -

Deepak Goel

unread,
Aug 22, 2012, 5:37:17 AM8/22/12
to webd...@googlegroups.com
I tried with IE9 and selenium 2.25 but the problem is still coming

Mike Riley

unread,
Aug 22, 2012, 2:25:09 PM8/22/12
to webd...@googlegroups.com
Deepak,

In my case a pop-up always was in response to something being clicked, so I wrote a routine to handle it.  It returns the handle of your current window, so you can switch back easily.  It finds the new window by looking to see what comes up after it does the click().

Here is the code:
    /**
     * This is used when clicking on some page element causes a new window to
     * pop up, which can either be a new floating window or a new tab. It will
     * do the click on the element and then switch to the new window. It returns
     * the handle for the current window so you can switch back to it once you
     * have finished with the pop up window. It will ignore "Timed out" errors
     * in the belief that they are false<br/> <br/> After we switch to the new
     * window we do a
     * <code>selenium.waitForPageToLoad()</code> before returning to the caller.
     * Be sure to check for the first element you wish to interact with right,
     * or what you think is the last of the dynamic page elements created by
     * JavaScript, after this call returns to be sure it is present using
     * <code>helper.waitForElementPresent()</code>.
     * @param element The <code>WebElement</code> to do      *                the <code>.click()</code> for.
     * @throws Exception
     * @see #waitForElementPresent(java.lang.String)
     * @see #waitForElementPresent(java.lang.String, int)
     * @see #waitForElementPresent(org.openqa.selenium.By)
     * @see #waitForElementPresent(org.openqa.selenium.By, int)
     */
    public String clickAndPopupWindow(WebElement element) throws Exception
    {
        String newWindow;
        Iterator<String> iterator;
        String oldWindow = driver.getWindowHandle();
        Set<String> oldSet = driver.getWindowHandles();
        Set<String> newSet = oldSet;

        try
        {   // PENDING If this solves the false timeout we need a click() wrapper method
            element.click();
        }   // try
        catch (Exception ex)
        {   // Check to make sure the exception is valid before throwing it
            if (!ex.getMessage().startsWith(timedOutPrefix))
                throw ex;
        }   // catch

        timer.setInitialDelay(timeout);
        timer.start();
        while (newSet.size() == oldSet.size() && !timerExpired)
        {   // Wait for the new window to be displayed
            Thread.sleep(100);  // Wait .1 seconds
            newSet = driver.getWindowHandles(); // See if the new window is up
        }   // while

        timer.stop();
        if (timerExpired)
            throw new Exception("No new window was created after clicking: " +
                                element.toString());

        iterator = newSet.iterator();
        do
        {   // Find which one is the new window
            newWindow = iterator.next();
        } while (oldSet.contains(newWindow) && iterator.hasNext());

        driver.switchTo().window(newWindow);
        selenium.waitForPageToLoad(timeoutString);
        return oldWindow;
    }   // clickAndPopupWindow(WebElement element)

    /**
     * This is used when clicking on some page element causes a new window to
     * pop up, which can either be a new floating window or a new tab. It will
     * do the click on the element and then switch to the new window. It returns
     * the handle for the current window so you can switch back to it once you
     * have finished with the pop up window. It will ignore "Timed out" errors
     * in the belief that they are false<br/> <br/> After we switch to the new
     * window we do a
     * <code>selenium.waitForPageToLoad()</code> before returning to the caller.
     * Be sure to check for the first element you wish to interact with right,
     * or what you think is the last of the dynamic page elements created by
     * JavaScript, after this call returns to be sure it is present using
     * <code>helper.waitForElementPresent()</code>.
     * @param locator The By class locator to do the
     *                <code>driver.findElement().click()</code> for.
     * @throws Exception
     * @see #waitForElementPresent(java.lang.String)
     * @see #waitForElementPresent(java.lang.String, int)
     * @see #waitForElementPresent(org.openqa.selenium.By)
     * @see #waitForElementPresent(org.openqa.selenium.By, int)
     */
    public String clickAndPopupWindow(By locator) throws Exception
    {
        waitForElementPresent(locator);
        return clickAndPopupWindow(driver.findElement(locator));
    }   // clickAndPopupWindow(By locator)

Manoj

unread,
Aug 24, 2012, 4:11:15 PM8/24/12
to webd...@googlegroups.com
Deepak,

Use this

  String parentwindow=driver.getWindowHandle();
     System.out.println(parentwindow);
     driver.findElement(By.id("")).click();
     driver.getWindowHandles();
     java.util.Set<String> availableWindows;
     while(true){
    availableWindows=driver.getWindowHandles();
     if(availableWindows.size()==2)
    break;
     }
     
     System.out.println(availableWindows.size());
     String popup=null;
      for(String win:availableWindows){
     if(!win.equals(parentwindow)){
     popup=win;
     driver.switchTo().window(popup);
     System.out.println(driver.getTitle());


--Manoj Hans

Mike Riley

unread,
Oct 5, 2012, 7:37:36 PM10/5/12
to webd...@googlegroups.com
I am guessing you have something else going on here.  Please start a new thread and post the HTML + JavaScript code you are using.  I would guess that what you think of as a "window" really isn't one, but simply looks like one and JavaScript is simply making it visible.

Mike

On Wednesday, October 3, 2012 8:41:20 AM UTC-7, William Nitchie wrote:
IE : 64 bit Version 8.0.7601
Selenium Webdriver: Version 2.25.0
Java environment: 1.6.0_23
 
I was having ths same issues that Deepak is having accessing the window handle for a popup in my application using IE as the browser. I tried the two alternatives above from Mike Riley and Manoj Hans and got the same result, the getWindowHandle call seems to return the main window handle only.  And after using the 2 alternatives above the wait procedure that waits for a new popup handle to be present just waits and never comes out of the loop or timesout.  My link is a javascript call to the window.open method and works fine to open up the window.  One other observation though is that I get a javascript error in the main popup calling window.  Wondering if this could be blocking something from happening.  It's odd that i'm getting the javascript errors because when I normally click on this link through the application I'm not getting an javascript errors.
 
Please let me know if anyone knows that this a legitamate bug and will never work and/or if there are other alternatives to accessing the window handles that might work in IE. 
 
Bill

Lokesh Kumar

unread,
Oct 9, 2012, 8:06:56 AM10/9/12
to webd...@googlegroups.com
If it is recognizing as separate window on FF then I would guess that issue is with sync. You can use explicit wait after the action which opens a new window. The reason we need explicit wait for IE is because IE is comparatively slow when compared to FF. You might be looking for the new window before it even opened. Hope it helps.

Lokesh

darrell

unread,
Oct 10, 2012, 11:15:18 AM10/10/12
to webd...@googlegroups.com
Mike,

This is a really nice method. Thanks for sharing. Just curious, why are you iterating over the set of window handles? I use:

    newSet.removeAll(oldSet);
    newWindow = newSet.toArray()[0];

Do you find the iterator loop to be faster the using removeAll then converting to an array?

Darrell

Mike Riley

unread,
Oct 10, 2012, 1:40:05 PM10/10/12
to webd...@googlegroups.com
I did it because I didn't know about removeAll() when I wrote it.  Since it worked fine, I never changed it.

Mike

Akarsh

unread,
Apr 10, 2013, 10:51:29 PM4/10/13
to webd...@googlegroups.com

I am also facing same problem, webdriver not detecting new pop up, driver.getWindowHandles() returning single window in ie in mozilla it is working fine. This is replicating with all the my web applications. Earlier it was working and it is still working in other machine.
WebDriver version 2.21
       Internet Explorer 8
       OS: Win XP
       Language used: java
       FF 11

No idea; seems not a issue from coding, some ie settings.  Please help if any body also faced same issue. 

Mike Riley

unread,
Apr 13, 2013, 4:50:57 PM4/13/13
to webd...@googlegroups.com
Since there are many ways to get a pop-up window, which in many cases isn't even a real window, it would help to see the HTML code involved to see what is going on.  An accompanying screen shot is also sometimes helpful, but seeing the code is the most helpful to get an answer.

Mike

jiming cai

unread,
Sep 19, 2013, 2:10:01 AM9/19/13
to webd...@googlegroups.com
This work for me. Thanks!

在 2013年5月30日星期四UTC+2上午4时08分08秒,Andy Fang写道:
This work for me.
Thanks Yang!

On Thursday, March 7, 2013 3:26:42 PM UTC+9, Jay Yang wrote:
Hi,

I encounter same issue, but it was resolved now.

Root cause: On IE 7 or higher on Windows Vista or Windows 7, you must set the Protected Mode settings for each zone to be the same value. The value can be on or off, as long as it is the same for every zone. To set the Protected Mode settings, choose "Internet Options..." from the Tools menu, and click on the Security tab. For each zone, there will be a check box at the bottom of the tab labeled "Enable Protected Mode".

Hope it works for you.

Thanks,
Jay Yang

在 2012年3月29日星期四UTC+8上午1时11分54秒,Akshay Rudraksha写道:

Amarjit Singh

unread,
Nov 5, 2013, 10:51:31 AM11/5/13
to webd...@googlegroups.com
Mr Darrell, Akashay is clearly saying that webdriver does not have window handle to newly pop up window,
he is saying:

"getWindowHandles() but it just return single window."

What more info we need here?

Webdriver maintains the list of all the window handles but for IE it does not work. As Akshay said his code works for Chrome and FF.

Jim Evans

unread,
Nov 6, 2013, 10:09:44 AM11/6/13
to webd...@googlegroups.com
And Darrell gave a decent list of places to start with the information someone would need to be able to have a hope of a chance of debugging and troubleshooting the issue. Handling popup windows in IE, and getting the correct list of window handles, is not globally broken for all sites nor all users. The Selenium project has continuous integration tests[1] that are run on 5 versions of IE for every commit, tests which include handling of popup windows, and these tests are passing.

One of the largest deficiencies in people saying, "I tried to do X, and it works in Firefox and/or Chrome, but doesn't work for IE," is that they are rarely willing to provide an HTML page or a link to a public URL where the problem can be reproduced[2]. This reluctance is often blown off by saying, "The application code is internal and I can't provide the HTML." This is Evans Bogus Reason #2, and is an excuse, not a legitimate reason. Remember, WebDriver code that looks identical can easily work with one HTML page, but fail with another, so having the page being automated is critical to success.

--Jim

[1] http://ci.seleniumhq.org:8080/
[2] http://jimevansmusic.blogspot.com/2012/12/not-providing-html-page-is-bogus.html

Kevin Chang

unread,
Nov 12, 2013, 9:57:15 PM11/12/13
to webd...@googlegroups.com
Hi Jim~

This is my first time joining a Google Groups; hoping this reply is visible to all.

I'm getting the same problem in my selenium test. I am writing a Selenium test from within a JUnit framework. When I try to grab the window handles, I'm not able to detect any additional window handles. In my jsp code:

var url      = "/loading.jsp?url=/orders/validate/productvalidate.jsp&"  + <some code to concatenate more query params>;;
var smallWin = window.open(url, 'popwindow', 'scrollbars=yes,resizable=yes,toolbar=no,height=480,width=471');

if (smallWin.opener == null) {
smallWin.opener = window;
}

The Selenium test up to this point is for automating the creation of a shipment from within the UI.

I've tried combinations of Thread.sleep(...) and detecting driver.getWindowHandles().size() inside while loops, and they all suggest that the popup window never comes to existence. In my UI, my popup window does indeed show up. The context as far as code logic is that a user enters a SKU#; if there's a match, the popup window briefly surfaces and then disappears and updates the main window; if there isn't a match, the popup window appears and stays with a list of possible matches. I have tried:
1) Entering a non-matched SKU#, so as to allow the popup window to stay in existence. In this case, I'd like Selenium to simply pick the first available link, click on it, and switch back to the main window. I can't switch to the popup window.
2) Entering a SKU# that registers a match; the popup window appears and disappears immediately. However, on the next "driver.findElement(...)" call, selenium throws an error:

org.openqa.selenium.remote.UnreachableBrowserException: Error communicating with the remote browser. It may have died.
Build info: version: '2.31.0', revision: '1bd294d', time: '2013-02-27 20:53:56'
System info: os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.6.0_29'
Driver info: driver.version: RemoteWebDriver

3) Thought perhaps the window could get consumed as an alert. I tried coupling a WebDriverWait (waiting till the alert was present), then driver.switchTo().alert(). No luck here.

I am using InternetExplorerDriver 64-bit, 2.31.0.0; selenium 2.35.0; IE9.0.8112.16421 (64 bit), Windows 7. Would be happy to provide you any other info; thanks in advance.

Jim Evans

unread,
Nov 15, 2013, 5:42:54 PM11/15/13
to webd...@googlegroups.com
You're using 2.31.0 of IEDriverServer.exe. There have been a fair number of changes in popup detection between then and the latest releases. I highly recommend you update that component. The latest public release is 2.37.0.0[1], and even further enhancements have been made since. You can always look for the latest in the project's git repo[2].

--Jim

[1] http://code.google.com/p/selenium/downloads/list
[2] http://selenium.googlecode.com/git/cpp/prebuilt/Win32/Release. Note that you can also use x64/Release.

susanth.nair

unread,
Nov 16, 2013, 12:15:56 AM11/16/13
to webd...@googlegroups.com
found that this issue happens when the url has the ip number instead of domain , check your URL




--
You received this message because you are subscribed to the Google Groups "webdriver" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webdriver+...@googlegroups.com.

To post to this group, send email to webd...@googlegroups.com.

manju. inform

unread,
Jan 1, 2014, 11:23:08 AM1/1/14
to webd...@googlegroups.com
@yang

even i am facing same issue even after passing "caps" as below control is not being navigated to pop up window,

DesiredCapabilities caps = DesiredCapabilities.internetExplorer();
caps.setCapability(
       InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,
   true);
WebDriver driver = new InternetExplorerDriver(caps);
- as  "Protected Mode settings" are manged by Admin, i do not have rights to un check

Configuration :

- Windows 7 with IE8 browser
- IEDriverServer_x64_2.39.0.zip
- selenium-server-standalone-2.39.0.jar

could any one suggest what should be done to pass control pop up window,
as same works well in Windows XP and IE8

thanks in advance

On Thursday, 7 March 2013 11:56:42 UTC+5:30, Jay Yang wrote:
Hi,

I encounter same issue, but it was resolved now.

Root cause: On IE 7 or higher on Windows Vista or Windows 7, you must set the Protected Mode settings for each zone to be the same value. The value can be on or off, as long as it is the same for every zone. To set the Protected Mode settings, choose "Internet Options..." from the Tools menu, and click on the Security tab. For each zone, there will be a check box at the bottom of the tab labeled "Enable Protected Mode".

Hope it works for you.

Thanks,
Jay Yang

在 2012年3月29日星期四UTC+8上午1时11分54秒,Akshay Rudraksha写道:


http://tester-learning.blogspot.in/

unread,
Jan 20, 2014, 6:02:48 AM1/20/14
to webd...@googlegroups.com

I am currently automating an application based on IBM Cognos platform  using selenium + Cucumber + Internet Explorer and is facing some challenges. I need some expert help from this group on the issues.

Problem Description -  Upon clicking a  link on the page, new browser get opened. Ideally, getWindowHandles() method returns correct count of browser opened by WebDriver. We switch to 2nd browser using window handle property, further action will be performed on second browser. GetWindowHandles is returning value 1 irrespective of number of browser opened by WebDriver. I have tried following methods  –


1.       Click() on the link & tried getWindowHandles()

2.       Keys.Enter on the link & getWindowHandles()

3.       sendkeys(“\0”) on the link & getWindowHandles()

4.       MouseHover on the link, click on the link & getWindowHandles

5.       Double click on the link & getWindowHandles

6.       Opened New tab using sendkeys(keys.control +”t”), navigated to URL & getWindowHandles()

7.       Opened new browser window using sendkeys(keys.control +”n”), navigated to URL & getWindowHandles()

 

Environment used –

                Selenium WebDriver – 2.39.0

                IEDriverServer.exe - Win32_2.39.0

                Windows 7

                Internet Explorer 8.0

Note – it is working fine on Firefox, this issue is happening on IE only.

Any help/suggestion will be highly appreciated.

darrell

unread,
Jan 20, 2014, 6:55:44 AM1/20/14
to webd...@googlegroups.com
I have always found it best to replicate what you do when testing something manually. Often there are things you will do or wait for when manually testing an application that you forget to do when automating. For example, you indicate the first thing you tried was:

    1. Click() on the link & tried getWindowHandles()

However, what you really do when manually testing is:

    1. Click on the link, WAIT FOR THE NEW WINDOW TO OPEN, interact with the new window.

Internet Explorer is notorious for being slow. The wait time for Chrome and Firefox in many cases is faster than your automation. So by the time you are ready to interact with the new window, it is already open. However on Internet Explorer, the wait time is much longer. Rather than 20ms it might be 210ms. From a manual tester perspective the time difference is immeasurable but from an automation perspective it makes a huge difference.

What you might need to do is get a list of the current window handles, click the link which opens a new window, then loop. The loop would check to see if the current number of window handles is greater than the previous window handles. You might need to check every 100ms for up to a few seconds. When the count increases you know the new window is ready to use.

If you try this and no window appears after say 10 seconds then something else is wrong. You'd have to dig more into the code which opens the new window and see if it is opening the window in a way that Selenium does not detect it.

Abhay Bharti

unread,
Jan 20, 2014, 7:01:22 AM1/20/14
to webd...@googlegroups.com
I have put wait (using thread.sleep(15000) & run number of times in debug mode. I executed getWindowHandles() only after new browser completes loading. In one case, I opend 4-5 different child browser & executed getWindowHandles() method. In all scenario, it is returning value 1.

--
You received this message because you are subscribed to a topic in the Google Groups "webdriver" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/webdriver/ULInjMbv5mU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to webdriver+...@googlegroups.com.

Jim Evans

unread,
Jan 20, 2014, 7:44:04 AM1/20/14
to webd...@googlegroups.com
You haven't mentioned the all-important Protected Mode settings for IE. By far, the two biggest causes of this issue are (1) not waiting for the window; and (2) not bothering to set the Protected Mode settings properly, relying instead on the INTRODUCE_FLAKINESS capability. Not setting the Protected Mode settings is the Wrong Thing[1] to do. Beyond that, you've provided no sample code (including HTML[2]) to reproduce your problem. I'd be happy to look into whatever you problem you think you have, but until you've provided enough information to go on, there's very little I can do.

[1] http://jimevansmusic.blogspot.com/2012/08/youre-doing-it-wrong-protected-mode-and.html
[2] http://jimevansmusic.blogspot.com/2012/12/not-providing-html-page-is-bogus.html?m=1

http://tester-learning.blogspot.in/

unread,
Jan 20, 2014, 8:26:20 AM1/20/14
to webd...@googlegroups.com
Hey Jim,

Protected Mode Setting is Off. I have put thread.sleep(15000). I executed my code multiple times in debug mode & make sure that target URL is completely loaded in IE. If you need more info, please let me know.

Jim Evans

unread,
Jan 20, 2014, 10:08:14 AM1/20/14
to webd...@googlegroups.com
I'm sorry. I thought I was entirely explicit about what further information someone would need to help you. Let me quote from my reply:

"Beyond that, you've provided no sample code (including HTML[1]) to reproduce your problem."

If you have any question about what that entails, I'd encourage you to read the blog post linked to in the footnote.

--Jim

[1] http://jimevansmusic.blogspot.com/2012/12/not-providing-html-page-is-bogus.html

Chris Merrill

unread,
Jan 20, 2014, 10:30:37 AM1/20/14
to webd...@googlegroups.com
:> :> :>

Your blog gave me a good chuckle this morning. Thanks, Jim!


On 1/20/2014 10:08 AM, Jim Evans wrote:
> I'm sorry. I thought I was entirely explicit about what further information someone would need to
> help you. Let me quote from my reply:
>
> "Beyond that, you've provided no sample code (including HTML[1]) to reproduce your problem."
>
> If you have any question about what that entails, I'd encourage you to read the blog post linked to
> in the footnote.
>
> --Jim
>
> [1] http://jimevansmusic.blogspot.com/2012/12/not-providing-html-page-is-bogus.html
> <http://www.google.com/url?q=http%3A%2F%2Fjimevansmusic.blogspot.com%2F2012%2F12%2Fnot-providing-html-page-is-bogus.html%3Fm%3D1&sa=D&sntz=1&usg=AFQjCNEgzJ4SGk-YCVO2Avw-fweQwlECXA>
>
> On Monday, January 20, 2014 5:26:20 AM UTC-8, http://tester-learning.blogspot.in/ wrote:
>
> Hey Jim,
>
> Protected Mode Setting is Off. I have put thread.sleep(15000). I executed my code multiple times
> in debug mode & make sure that target URL is completely loaded in IE. If you need more info,
> please let me know.
>
> On Monday, 20 January 2014 18:14:04 UTC+5:30, Jim Evans wrote:
>
> You haven't mentioned the all-important Protected Mode settings for IE. By far, the two
> biggest causes of this issue are (1) not waiting for the window; and (2) not bothering to
> set the Protected Mode settings properly, relying instead on the INTRODUCE_FLAKINESS
> capability. Not setting the Protected Mode settings is the Wrong Thing[1] to do. Beyond
> that, you've provided no sample code (including HTML[2]) to reproduce your problem. I'd be
> happy to look into whatever you problem you think you have, but until you've provided enough
> information to go on, there's very little I can do.
>
> [1] http://jimevansmusic.blogspot.com/2012/08/youre-doing-it-wrong-protected-mode-and.html
> <http://jimevansmusic.blogspot.com/2012/08/youre-doing-it-wrong-protected-mode-and.html>
> [2] http://jimevansmusic.blogspot.com/2012/12/not-providing-html-page-is-bogus.html?m=1
> <http://jimevansmusic.blogspot.com/2012/12/not-providing-html-page-is-bogus.html?m=1>
>
> --
> You received this message because you are subscribed to the Google Groups "webdriver" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
> webdriver+...@googlegroups.com.
> To post to this group, send email to webd...@googlegroups.com.
> Visit this group at http://groups.google.com/group/webdriver.
> For more options, visit https://groups.google.com/groups/opt_out.


--
------------------------------------------------------------------------ -
Chris Merrill | Web Performance, Inc.
ch...@webperformance.com | http://webperformance.com
919-433-1762 | 919-845-7601

Web Performance: Website Load Testing Software & Services
------------------------------------------------------------------------ -

Øystein

unread,
Jan 21, 2014, 3:17:58 AM1/21/14
to webd...@googlegroups.com
I second that:) thanks Jim

-----Original Message-----
From: webd...@googlegroups.com [mailto:webd...@googlegroups.com] On Behalf Of Chris Merrill
Sent: 20. januar 2014 16:31
To: webd...@googlegroups.com
Subject: Re: [webdriver] Re: getWindowHandles() return only 1 window in IE

:> :> :>

Your blog gave me a good chuckle this morning. Thanks, Jim!


On 1/20/2014 10:08 AM, Jim Evans wrote:
> I'm sorry. I thought I was entirely explicit about what further
> information someone would need to help you. Let me quote from my reply:
>
> "Beyond that, you've provided no sample code (including HTML[1]) to reproduce your problem."
>
> If you have any question about what that entails, I'd encourage you to
> read the blog post linked to in the footnote.
>
> --Jim
>
> [1]
> http://jimevansmusic.blogspot.com/2012/12/not-providing-html-page-is-b
> ogus.html
> <http://www.google.com/url?q=http%3A%2F%2Fjimevansmusic.blogspot.com%2
> F2012%2F12%2Fnot-providing-html-page-is-bogus.html%3Fm%3D1&sa=D&sntz=1
> &usg=AFQjCNEgzJ4SGk-YCVO2Avw-fweQwlECXA>
>
> On Monday, January 20, 2014 5:26:20 AM UTC-8, http://tester-learning.blogspot.in/ wrote:
>
> Hey Jim,
>
> Protected Mode Setting is Off. I have put thread.sleep(15000). I executed my code multiple times
> in debug mode & make sure that target URL is completely loaded in IE. If you need more info,
> please let me know.
>
> On Monday, 20 January 2014 18:14:04 UTC+5:30, Jim Evans wrote:
>
> You haven't mentioned the all-important Protected Mode settings for IE. By far, the two
> biggest causes of this issue are (1) not waiting for the window; and (2) not bothering to
> set the Protected Mode settings properly, relying instead on the INTRODUCE_FLAKINESS
> capability. Not setting the Protected Mode settings is the Wrong Thing[1] to do. Beyond
> that, you've provided no sample code (including HTML[2]) to reproduce your problem. I'd be
> happy to look into whatever you problem you think you have, but until you've provided enough
> information to go on, there's very little I can do.
>
> [1] http://jimevansmusic.blogspot.com/2012/08/youre-doing-it-wrong-protected-mode-and.html
> <http://jimevansmusic.blogspot.com/2012/08/youre-doing-it-wrong-protected-mode-and.html>
> [2] http://jimevansmusic.blogspot.com/2012/12/not-providing-html-page-is-bogus.html?m=1
>
> <http://jimevansmusic.blogspot.com/2012/12/not-providing-html-page-is-
> bogus.html?m=1>
>
> --
> You received this message because you are subscribed to the Google Groups "webdriver" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to
> webdriver+...@googlegroups.com.
> To post to this group, send email to webd...@googlegroups.com.
> Visit this group at http://groups.google.com/group/webdriver.
> For more options, visit https://groups.google.com/groups/opt_out.


--
------------------------------------------------------------------------ -
Chris Merrill | Web Performance, Inc.
ch...@webperformance.com | http://webperformance.com
919-433-1762 | 919-845-7601

Web Performance: Website Load Testing Software & Services
------------------------------------------------------------------------ -

--
You received this message because you are subscribed to the Google Groups "webdriver" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webdriver+...@googlegroups.com.

Teja Neelisetty

unread,
Feb 4, 2014, 1:22:12 AM2/4/14
to webd...@googlegroups.com


On Thursday, March 29, 2012 7:34:26 PM UTC+5:30, Santosh Kumar K wrote:
Try this,,

       // before clicking on the link
        String parent = driver.getWindowHandle();

       // after clicking on the link
        Thread.sleep(1000);
        Set<String> availableWindows = driver.getWindowHandles();
        String newWindow = null;
        for (String window : availableWindows) {
            if (!parent.equals(window)) {
                newWindow = window;
            }
        }
        assertNotNull(newWindow);

        // switch to new window
        driver.switchTo().window(newWindow);
        // do assert the elements in the new window
        // and then close the new window
        driver.close();
        // switch to parent
        driver.switchTo().window(parent);
        // close main window
        driver.close();

 hope it helps you :) cheers,,,


On Thu, Mar 29, 2012 at 7:17 PM, Akshay Rudraksha <aksh...@gmail.com> wrote:
Webdriver - 2.20 Latest selenium version
IE - IE8
FF and Chrome works fine - Chrome 17....FF- 11
Lang Used - Java
Steps to Reproduce - 
 -Enter Login Credential hit Sigon it provide you link to Application
- By hitting on any of the link will open new Window which is not being recognized.



Below is the code i used to Click on link - 



//Driver.driver.switchTo().window("Commercial Electronic Office");
String Login = Driver.driver.getWindowHandle();

Driver.driver.findElement(By.xpath("//a[contains(text(),'Exchange')]")).sendKeys(Keys.RETURN);
//Thread.sleep(10000);
for (String handle1 : Driver.driver.getWindowHandles()) { // This is where i am not getting any window, it just show default Login window...





On Thu, Mar 29, 2012 at 5:30 AM, darrell <darrell....@gmail.com> wrote:
Not really a lot to go on here. When you post a question, think of it like posting a defect report. The more information you can provide the more likely the problem will get resolved.

  • Which version of WebDriver?
  • Which version of IE?
  • Which version of Firefox or Chrome?
  • Which language are you programming in?
  • Do you have an example of the code which opens a window?
  • Please provide a list of steps to reproduce.
  • Have you looked at the differences in the web page, Firefox versus IE?
With the information you have provided the best you can hope for are wild guesses.


On Wednesday, 28 March 2012 13:11:54 UTC-4, Akshay Rudraksha wrote:


On Tue, Mar 27, 2012 at 11:55 AM, Akshay Rudraksha <aksh...@gmail.com> wrote:
I am stuck at place where IE unable to get details of new Popup window, i tried to using getWindowHandles() but it just return single window. It's not even wait issue as the window does get open in few sec (I did tried putting sleep)

With Firefox and Chrome i am able to get handle of new window...





--
--
Akshay Rudraksha






--
--
Akshay Rudraksha
Synechron Technologies Pvt. Ltd,
Wells Fargo Bank,San Francisco,CA
Cell - 1-925-353-8210



--
You received this message because you are subscribed to the Google Groups "webdriver" group.
To view this discussion on the web visit https://groups.google.com/d/msg/webdriver/-/ozIY5vQ4KhsJ.

To post to this group, send email to webd...@googlegroups.com.
To unsubscribe from this group, send email to webdriver+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/webdriver?hl=en.



--
--
Akshay Rudraksha
Synechron Technologies Pvt. Ltd,
Wells Fargo Bank,San Francisco,CA
Cell - 1-925-353-8210



--
You received this message because you are subscribed to the Google Groups "webdriver" group.
To post to this group, send email to webd...@googlegroups.com.
To unsubscribe from this group, send email to webdriver+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/webdriver?hl=en.



--
Santosh Kumar K


Hi Santhosh,

I need to handle a new window when it get opens with the old window in IE 6.

I have tried the logic you mentioned but i am getting stuck in the first command only "String parent = driver.getWindowHandle();"

I am using IE 6 version and with Java code in eclipse tool.

Please help me to resolve this
Reply all
Reply to author
Forward
Message has been deleted
Message has been deleted
0 new messages