Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IEDriver] fix Edge IE mode issue that sometimes cannot get the handle of a newly opened window #10702

Merged
merged 6 commits into from
Jul 12, 2022

Conversation

yusuke-noda
Copy link
Contributor

Description

Fix Edge IE mode issue that sometimes cannot get the handle of the newly opened window.

Motivation and Context

This is a fix for an issue of Edge IE mode that sometimes cannot get the handle of a newly opened window.
Resolve #8868
Resolve MicrosoftEdge/EdgeWebDriver#19

Reproduction steps

Attached zip file contains test programs to reproduce of the issue.
iedrivertest.zip

  1. Install node_modules
    npm install
  2. Run server.
    node server.js
  3. Run tests several times.
    node test.js --edge-path "path\to\msedge.exe" --driver-path "path\to\IEDriverServer.exe"
    node test2.js --edge-path "path\to\msedge.exe" --driver-path "path\to\IEDriverServer.exe"
    node test3.js --edge-path "path\to\msedge.exe" --driver-path "path\to\IEDriverServer.exe"
    node test4.js --edge-path "path\to\msedge.exe" --driver-path "path\to\IEDriverServer.exe"
    node test5.js --edge-path "path\to\msedge.exe" --driver-path "path\to\IEDriverServer.exe"

Contents of test programs

  1. test.js
    Open one child window and check that can get window handle of the child window.
  2. test2.js
    Open four child window and check that can get window handles of all of the child windows.
  3. test3.js
    Open four child tabs in the same window that contains the parent tab and check that can get window handles of all of the child tabs.
  4. test4.js
    Open child window and its grandchild window at same time and close child window immediately, then check that can get window handle of grandchild windows.
  5. test5.js
    Open child window and its grandchild window at same time, then check that can get window handle of child and grandchild windows.

Unresolved problem

Open child and its grandchild tabs in the same window that contains the parent tab at same time, IEDriver cannot get window handle of the child tab.
node test6.js --edge-path "path\to\msedge.exe" --driver-path "path\to\IEDriverServer.exe"

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • I have read the contributing document.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

… to appear.

A part of the fixes for issues that occur in Edge IE mode.

There is a thread that uses SendMessage to send WM_USER in the mouse click process, and this thread goes into a wait state.
If this is not done, the new browser window will never be displayed.
Therefore, you need to process the WM_USER message while waiting for a new window to appear.
…hing to the window.

A part of the fixes for issues that occur in Edge IE mode.

When a new browser window appears and closes immediately, IEDriver may try to attach to a window that doesn't exist.
To solve this problem, check that the window process exists before attaching to the window.
…d window.

A part of the fixes for issues that occur in Edge IE mode.

If the grandchild window opens before it is attached to the child window, IEDriver cannot detect the appearance of the grandchild window.
Therefore, if a child window and a grandchild window appear at the same time, the handle of the grandchild window cannot be obtained.
To solve this problem, add wait to wait for the grandchild window to appear, and attach to all elements of diff list.
@CLAassistant
Copy link

CLAassistant commented May 27, 2022

CLA assistant check
All committers have signed the CLA.

@ven92
Copy link

ven92 commented Jun 9, 2022

I'm facing the same issue. I tried with IE driver v4.0 & v4.2. MS Edge is getting launched in IE Mode, window handle works when only one Window present. But if multiple window gets open, then the code get stuck at driver.window_handles line. Could you please provide the ASAP..

@JeyBee83
Copy link

Any updates on this? A merge would be very helpful, we have lots of issues with this.

@bwalderman
Copy link
Contributor

When I built and tested IEDriverServer this change, I found that test.js, test2.js and test3.js are more stable, but test4.js and test5.js are still failing. @yusuke-noda does this match your expectations?

Log from test4.js:

> node .\test4.js --driverPath=IEDriverServer.exe --edgePath="C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe"
start
iteration start 0
retry
retry
retry
Error: too many retry
    at C:\Users\brwalder\Desktop\iedrivertest\test4.js:51:17
    at processTicksAndRejections (node:internal/process/task_queues:94:5)
finally

Log from test5.js:

> node .\test5.js --driverPath=IEDriverServer.exe --edgePath="C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe"
start
iteration start 0
retry
retry
retry
Error: too many retry
    at C:\Users\brwalder\Desktop\iedrivertest\test5.js:51:17
    at processTicksAndRejections (node:internal/process/task_queues:94:5)
finally

@yusuke-noda
Copy link
Contributor Author

Hello @bwalderman .
On my environments (Windows 10 21H2 and Windows 11), test4.js and test5.js are also stable.

node .\test4.js --driver-path .\IEDriverServer.exe --edge-path "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe"
start
iteration start 0
iteration finished 0
iteration start 1
iteration finished 1
iteration start 2
iteration finished 2
iteration start 3
iteration finished 3
iteration start 4
iteration finished 4
iteration start 5
iteration finished 5
iteration start 6
iteration finished 6
iteration start 7
iteration finished 7
iteration start 8
iteration finished 8
iteration start 9
iteration finished 9
iteration start 10
iteration finished 10
iteration start 11
iteration finished 11
iteration start 12
iteration finished 12
iteration start 13
iteration finished 13
iteration start 14
iteration finished 14
iteration start 15
iteration finished 15
iteration start 16
iteration finished 16
iteration start 17
iteration finished 17
iteration start 18
iteration finished 18
iteration start 19
iteration finished 19
finally
node .\test5.js --driver-path .\IEDriverServer.exe --edge-path "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe"
start
iteration start 0
[ 'child51', 'child52' ]
iteration finished 0
iteration start 1
[ 'child51', 'child52' ]
iteration finished 1
iteration start 2
[ 'child51', 'child52' ]
iteration finished 2
iteration start 3
[ 'child51', 'child52' ]
iteration finished 3
iteration start 4
[ 'child51', 'child52' ]
iteration finished 4
iteration start 5
[ 'child51', 'child52' ]
iteration finished 5
iteration start 6
[ 'child51', 'child52' ]
iteration finished 6
iteration start 7
[ 'child51', 'child52' ]
iteration finished 7
iteration start 8
[ 'child51', 'child52' ]
iteration finished 8
iteration start 9
[ 'child51', 'child52' ]
iteration finished 9
iteration start 10
[ 'child51', 'child52' ]
iteration finished 10
iteration start 11
[ 'child51', 'child52' ]
iteration finished 11
iteration start 12
[ 'child51', 'child52' ]
iteration finished 12
iteration start 13
[ 'child51', 'child52' ]
iteration finished 13
iteration start 14
[ 'child51', 'child52' ]
iteration finished 14
iteration start 15
[ 'child51', 'child52' ]
iteration finished 15
iteration start 16
[ 'child51', 'child52' ]
iteration finished 16
iteration start 17
[ 'child51', 'child52' ]
iteration finished 17
iteration start 18
[ 'child51', 'child52' ]
iteration finished 18
iteration start 19
[ 'child51', 'child52' ]
iteration finished 19
finally

But if "Always open pop-ups in a new tab" option is enabled in IE's tabbed Browsing Settings, test5.js fails same as test6.js

@Oleksii-tmnas
Copy link

hey guys any updates on this? looking forward to the changes to be merged...

@bwalderman
Copy link
Contributor

The "Always open pop-ups in a new tab" setting isn't visible in my Windows 11 environment anymore, probably because of the IE11 removal. So I can't verify that test5.js and test6.js would be fixed. However, the change looks good to me and the other test cases appear to be stable.

I've just left a couple suggestions to rename variables to match the style used in the rest of the code.

cpp/iedriver/IECommandExecutor.cpp Outdated Show resolved Hide resolved
cpp/iedriver/IECommandExecutor.cpp Outdated Show resolved Hide resolved
cpp/iedriver/IECommandExecutor.cpp Outdated Show resolved Hide resolved
Copy link
Member

@diemol diemol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for reviewing, @bwalderman!

Thank you for this PR, @yusuke-noda!

@diemol diemol merged commit 7296782 into SeleniumHQ:trunk Jul 12, 2022
@titusfortner
Copy link
Member

@anishamarotkar
Copy link

With Selenium Java version 4.4.0 or 4.3.0 and IE Driver 4.3.0 I am still getting facing the same issue. Can anyone please help?

@jyosha3
Copy link

jyosha3 commented Nov 22, 2022

getting the same issue with latest versions of IE driver and selenium java versions.Any one was able to find a solution or workaround?

@titusfortner
Copy link
Member

@anishamarotkar & @jyosha3 can you comment on MicrosoftEdge/EdgeWebDriver#19 we may need to re-open that.

@jyosha3
Copy link

jyosha3 commented Nov 23, 2022

@titusfortner Yes did comment on that issue just now.How can it be reopened though.I am new and came here looking for a solution so dont know how things work here.

@titusfortner
Copy link
Member

Yeah, since IEDriver is *only supported via Edge right now, the code management is being done in collaboration with Microsoft. So the current practice (subject to change) is to file the issue in MicrosoftEdge repo, and then the PRs are done here. @bwalderman is the person who would be able to re-open that issue. Also, you might need to provide more info with a trace log in a reproducible case if it is at all different from what has been previously reported.

@jyosha3
Copy link

jyosha3 commented Nov 24, 2022

@titusfortner ok .. thanks for the information.. i have provided a test scenario in the microsoft edge repo.. alongwith the exception i gt. @bwalderman do I need to provide any more details for u to reopen / address the issue.

@tenisaname
Copy link

Hello, are there any changes on this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet