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

[🐛 Bug]: Tab cannot be switched in IE compatibility mode of edge. #10701

Closed
accamo opened this issue May 27, 2022 · 19 comments
Closed

[🐛 Bug]: Tab cannot be switched in IE compatibility mode of edge. #10701

accamo opened this issue May 27, 2022 · 19 comments
Labels
G-msedgedriver Requires fixes in MSEdgeDriver I-defect

Comments

@accamo
Copy link

accamo commented May 27, 2022

What happened?

When I try to switch tab with driver.switchTo().window() at IE compatibility mode of edge,it doesn't work.

It worked using chrome and edge.

Detail

Currently, we are testing an application that requires tab switching using Edge IE mode.

Using driver.switchTo().window() code only changes the focus of the program.

During runtime, we observed that the above code does not change the focus of the screen.

We have come up to the solution of using driver.switchTo().window() and send key (CTRL + Tab) to switch both program and screen focus. However, since send keys are unstable (not returning any indication whether it successfully switched tab or not), we would like to know is it possible to have the driver.switchTo().window() code support both program and screen focus switch for Edge IE mode? Is it expected that driver.switchTo().window() only supports program focus?

Regarding tab and window, are there assurances that there is no difference in terms of data, function and control between window and tab?

Relevant log output

nothing

Operating System

Windows 10

Selenium version

selenium 4.1.2, java 11

What are the browser(s) and version(s) where you see this issue?

edge 101.0.1210.53

What are the browser driver(s) and version(s) where you see this issue?

IEDriverServer 4.0.0

Are you using Selenium Grid?

No response

@github-actions
Copy link

@accamo, thank you for creating this issue. We will troubleshoot it as soon as we can.


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then I-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C), add the applicable G-* label, and it will provide the correct link and auto-close the issue.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!

@titusfortner
Copy link
Member

I think this is a duplicate of #8868
The fix will be in IE Driver 4.2 which should be released very soon.

@accamo
Copy link
Author

accamo commented May 27, 2022

@titusfortner Thank you!
But the problem here seems different.
I can get the correct handles in the program, but the focus did not change to the tab I wanted.
I have provided additional explanation in the ticket description.

just in case, my driver configuration:

driver = {
			System.setProperty("webdriver.ie.driver", "./src/test/resources/driver/IEDriverServer.exe")
			InternetExplorerOptions options = new InternetExplorerOptions()
            options.requireWindowFocus()
			options.attachToEdgeChrome()
			options.withEdgeExecutablePath("C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe")
			def driver = new InternetExplorerDriver(options)
			driver.manage().window().maximize()
			driver}

@diemol diemol added I-issue-template Applied to issues not following the template, or missing information. and removed needs-triaging labels May 30, 2022
@diemol
Copy link
Member

diemol commented May 30, 2022

If the issue is different, then we need more information, please see below.

@github-actions
Copy link

Hi, @accamo.
Please follow the issue template, we need more information to reproduce the issue.

Either a complete code snippet and URL/HTML (if more than one file is needed, provide a GitHub repo and instructions to run the code), the specific versions used, or a more detailed description to help us understand the issue.

Note: If you cannot share your code and URL/HTML, any complete code snippet and URL/HTML that reproduces the issue is good enough.

Reply to this issue when all information is provided, thank you.

@titusfortner
Copy link
Member

Please try with latest IE Driver v4.2

@accamo
Copy link
Author

accamo commented Jun 2, 2022

@diemol
I'm sorry because there are so many packages and the code can't be exposed.
when using the IE compatibility mode of edge, clicking the link will open a new tab.
when switch tab,
The window switching is also successful in the background(java test), but the focus of the actual screen focus is not switched.

@accamo
Copy link
Author

accamo commented Jun 2, 2022

@titusfortner
Sorry, this problem still exists.
Is it because ie11 uses window instead of tab when using webdriver control?

@diemol
Copy link
Member

diemol commented Jun 2, 2022

Without a way to reproduce it we cannot tell if it is a Selenium issue or an issue in the IE mode of Edge. It does not need to be the same code you use internally, but something we can use to reproduce the issue.

@sargis-tovmasyan
Copy link

sargis-tovmasyan commented Jun 3, 2022

I am not able to test it on 4.2.0 because webdriver is stuck on the initial page and doesn't do anything...
but 4.0.0 has this issue
just create the driver open a new tab then try to switch back to the first tab (programmatically it is happening because I can run tests on the first tab but visually I cant see that tab was switched ...)

Try this to reproduce (Nuget versions: 4.0.0, IEDriverServer version: 4.0.0)

C#

var service = InternetExplorerDriverService.CreateDefaultService(DRIVER_DIRECTORY, DRIVER_NAME);
var ieOptions = new InternetExplorerOptions()
{
    PageLoadStrategy = PageLoadStrategy.None,
    Proxy = null,
    AttachToEdgeChrome = true,
    EdgeExecutablePath = @"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" //Default installation path...
};

var webDriver = new InternetExplorerDriver(service, ieOptions);

webDriver.Navigate().GoToUrl("http://bing.com");
var firstHandler = webDriver.CurrentWindowHandle;
webDriver.SwitchTo().NewWindow(WindowType.Tab);
webDriver.Navigate().GoToUrl("http://google.com");
webDriver.SwitchTo().Window(firstHandler);

//Automation on first page
var searchTextBox = webDriver.FindElement(By.Id("sb_form_q"));
var searchButton = webDriver.FindElement(By.Id("search_icon"));
searchTextBox.SendKeys("Test");
searchButton.Click();

Demo:

demo_switchTab_issue

@titusfortner
Copy link
Member

We can't do anything about 4.0, we can only fix problems in 4.2, so let's figure out why you can't get 4.2 working. What error do you get? What code are you using to start it?

@sargis-tovmasyan
Copy link

sargis-tovmasyan commented Jun 8, 2022

We can't do anything about 4.0, we can only fix problems in 4.2, so let's figure out why you can't get 4.2 working. What error do you get? What code are you using to start it?

Тhe same code as shown above! but with updated NuGet "WebDriver" and IEDriverServer.exe (both 4.2.0)
No errors/exceptions... only timeout error after 60 seconds (expected).

demo_4 2 0_start_issue

@diemol
Copy link
Member

diemol commented Jun 8, 2022

Can you please try what the Edge team suggests when opening new windows and then report back?
https://docs.microsoft.com/en-us/microsoft-edge/webdriver-chromium/ie-mode?tabs=c-sharp#opening-new-windows

@sargis-tovmasyan
Copy link

sargis-tovmasyan commented Jun 8, 2022

Can you please try what the Edge team suggests when opening new windows and then report back? https://docs.microsoft.com/en-us/microsoft-edge/webdriver-chromium/ie-mode?tabs=c-sharp#opening-new-windows

The issue is not in opening a new tab, the issue is in switching between opened tabs!

@sargis-tovmasyan
Copy link

sargis-tovmasyan commented Jun 8, 2022

UPD: running 4.2.0 from the %SOLUTION_DIR%/bin/Debug folder works!
Result: Tab not switched!

demo_4 2 0_start_issue_3

No error messages on the command line interface ...

@sargis-tovmasyan
Copy link

sargis-tovmasyan commented Jun 16, 2022

@diemol, @titusfortner is there any update on this?

@diemol
Copy link
Member

diemol commented Jun 16, 2022

I was troubleshooting this on my Windows machine and I was able to reproduce it. Somehow IEDriver does not switch back to the initial window handle. Here is the code I was using, also following the recommendation from the docs in Edge.

        static void Main(string[] args)
        {
            var ieOptions = new InternetExplorerOptions()
            {
                PageLoadStrategy = PageLoadStrategy.None,
                Proxy = null,
                AttachToEdgeChrome = true,
                EdgeExecutablePath = @"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe"
            };

            var webDriver = new InternetExplorerDriver(ieOptions);
            webDriver.Navigate().GoToUrl("http://bing.com");
            var firstHandler = webDriver.CurrentWindowHandle;
            webDriver.SwitchTo().NewWindow(WindowType.Tab);
            webDriver.Navigate().GoToUrl("http://google.com");
            webDriver.SwitchTo().Window(firstHandler); // Does not go to the initial window handle.
            Console.WriteLine(webDriver.WindowHandles.Count);
            webDriver.SwitchTo().Window(firstHandler);
            var newWindowHandle = webDriver.CurrentWindowHandle;
            Console.WriteLine("First handle: " + firstHandler);
            foreach (string window in webDriver.WindowHandles)
            {
                Console.WriteLine("Handle: " + window);
                if(newWindowHandle != window)
                {
                    webDriver.SwitchTo().Window(window);
                    break;
                }
            }
            Thread.Sleep(5000);

            //Automation on first page
            //var searchTextBox = webDriver.FindElement(By.Id("sb_form_q"));
            //var searchButton = webDriver.FindElement(By.Id("search_icon"));
            //searchTextBox.SendKeys("Test");
            //searchButton.Click();

            webDriver.Quit();
        }

There is not much we can do at the Selenium project since the Edge folks are the ones who are kindly helping to maintain the IEDriver. Please report this issue to their team. I will leave the links to report it below.

@diemol diemol added G-msedgedriver Requires fixes in MSEdgeDriver and removed I-issue-template Applied to issues not following the template, or missing information. labels Jun 16, 2022
@github-actions
Copy link

Hi, @accamo.
This issue has been determined to require fixes in MSEdgeDriver
or in the IE Mode in Edge.

You can see if the feature is passing in the Web Platform Tests.

If it is something new, please create an Issue with the MSEdgeDriver team.

Feel free to comment the issues that you raise back in this issue. Thank you.

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked and limited conversation to collaborators Jul 17, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
G-msedgedriver Requires fixes in MSEdgeDriver I-defect
Projects
None yet
Development

No branches or pull requests

4 participants