SeleniumHQ / selenium

A browser automation framework and ecosystem.
https://selenium.dev
Apache License 2.0
30.54k stars 8.16k forks source link

[🐛 Bug]: Internet Explorer driver doesn't accept POST /session/{sessionid}/print #11578

Open nwatab opened 1 year ago

nwatab commented 1 year ago

What happened?

I'm trying to convert XML and XSLT files into a PDF via Internet Explorer in C#. The fileis shown in IE without any problem, however, when I called driver.Print(newPrintOptions());, I came across the error shown below.

System.NotImplementedException: 'Command not found: POST /session/e809cfda-0282-4339-ab82-efd34881e4fc/print'

Because a driver gets timed out to load remote page (as there's no protected mode in Windows 11, i can't configure properly), I can't confirm this error is thrown even when browsing a remote page.

The environment is

How can we reproduce the issue?

var driver = new InternetExplorerDriver();
driver.Url = "file:\\\\\\C:\\path\\to\\file.xml";
PrintDocument printDocument = driver.Print(new PrintOptions());  // throws an error

Relevant log output

System.NotImplementedException
  HResult=0x80004001
  Message=Command not found: POST /session/e809cfda-0282-4339-ab82-efd34881e4fc/print
  Source=WebDriver
  stack trace:
   at OpenQA.Selenium.WebDriver.UnpackAndThrowOnError(Response errorResponse, String commandToExecute)
   at OpenQA.Selenium.WebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
   at OpenQA.Selenium.WebDriver.Print(PrintOptions printOptions)
   at XML2PDF.MainWindow..ctor() (C:\Users\MyName\source\repos\XML2PDF\XML2PDF\MainWindow.xaml.cs):line 58
   at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean wrapExceptions)

Operating System

Microsoft windows 11 Home Insider Preview (10.0.25281 Build 25281)

Selenium version

C# 4.7.0

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

Visual Studio 2022's debug mode. Microsoft Edge version109.0.1518.61 (official) (64bit) is called from Internet Explorer driver

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

Both of Internet Explorer 32bit 4.7.0 and 64bit 4.7.0

Are you using Selenium Grid?

No, I don't use Selenium Grid.

github-actions[bot] commented 1 year ago

@nwatab, 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!

diemol commented 1 year ago

This is not supported by IEDriver. I believe it is only supported in Chrome and Firefox.

nwatab commented 1 year ago

Thanks. then why driver has Print method... Edit: Print method https://github.com/SeleniumHQ/selenium/blob/1d723de63c8fdf16533f3bfed7ead17169776542/dotnet/src/webdriver/WebDriver.cs#L364-L369

diemol commented 1 year ago

Good point, we should check that.

titusfortner commented 1 year ago

@nwatab there are registry settings you can adjust to set protected mode for Edge in IE Mode, I discussed them here — https://titusfortner.com/2022/09/28/edge-ie-mode.html

Let us know if that fixes your issue.

nwatab commented 1 year ago

@titusfortner thanks for the article. Looks great. I'm not sure if it affects POST /print endpoints, but I'll give it a try. If I distribute my app to clients, should they also configure registry settings?

titusfortner commented 1 year ago

If they need to run Selenium with Edge in IE Mode and end up switching zones, then yes, they'll need to adjust registry settings as well.

Yeah, I don't know if it'll fix print endpoint, I just saw your reference to it, and if that part isn't working, other things won't work.

github-actions[bot] commented 9 months ago

This issue is looking for contributors.

Please comment below or reach out to us through our IRC/Slack/Matrix channels if you are interested.

titusfortner commented 9 months ago

So, this is a newer feature defined in w3c that IE Driver never implemented — https://w3c.github.io/webdriver/#print

I'm not sure how hard it is to add to our IE driver code, but none of the active contributors are C++ experts and so we are unlikely to prioritize this.

We'd welcome anyone interested in helping out to give it a shot to implement it. Thanks.

github-actions[bot] commented 1 week ago

This issue is stale because it has been open 280 days with no activity. Remove stale label or comment or this will be closed in 14 days.