-
Notifications
You must be signed in to change notification settings - Fork 115
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
Win32Exception thrown while attempting to take screenshot from remote machine #225
Comments
Yah that code is in a function called Alerts really mess up UI Automation because they are not a part of the DOM. They are not even an item in your current tab. They are a part of the browser at the same level/importance as a tab. They are basically outside of the scope of the actual website. When a alert is open, Selenium will not a take a screenshot. That function is an attempt to take a screenshot with Windows calls. I can try to reproduce the problem locally and improve the function. Long term, for your own sanity, its probably a good idea work towards removing and avoiding alerts, and using another mechanism for displaying things to your users. |
I've thought about this and the best thing I can do is to either A) not attempt a screenshot if its a remote server Either one acceptable to you? |
I think "B" is better solution, at least for me. Thank you. |
hello Chris, have you released the fix? thanks in advance |
Sorry for the delay! |
Thank you, solved my problems. |
Hi,
I can't provide clear steps to reproduce this issue, but it happens occasionally on the remote machine (never met it while running tests locally). Here is the stacktrace:
Unhandled Exception: System.ComponentModel.Win32Exception: The handle is invalid at System.Drawing.Graphics.CopyFromScreen(Int32 sourceX, Int32 sourceY, Int32 destinationX, Int32 destinationY, Size blockRegionSize, CopyPixelOperation copyPixelOperation) at canopy.core.takeScreenShotIfAlertUp() in C:\projects\canopy\src\canopy\canopy.fs:line 46 at canopy.core.takeScreenshot(String directory, String filename) in C:\projects\canopy\src\canopy\canopy.fs:line 60 at canopy.core.screenshot(String directory, String filename) in C:\projects\canopy\src\canopy\canopy.fs:line 68 at canopy.runner.fail(Exception ex, String id) in C:\projects\canopy\src\canopy\runner.fs:line 86 at canopy.runner.runtest$cont@110(suite suite, Test test, Unit unitVar) in C:\projects\canopy\src\canopy\runner.fs:line 123 at canopy.runner.runtest@105(suite suite, Test test) in C:\projects\canopy\src\canopy\runner.fs:line 110 at [email protected](Test w) in C:\projects\canopy\src\canopy\runner.fs:line 158 at Microsoft.FSharp.Primitives.Basics.List.iter[T](FSharpFunc
2 f, FSharpList1 x) at canopy.runner.run$cont@148(suite s, Unit unitVar) in C:\projects\canopy\src\canopy\runner.fs:line 158 at [email protected](suite s) in C:\projects\canopy\src\canopy\runner.fs:line 148 at Microsoft.FSharp.Primitives.Basics.List.iter[T](FSharpFunc
2 f, FSharpList1 x) at canopy.runner.run() in C:\projects\canopy\src\canopy\runner.fs:line 145 at Main.main(String[] argv) in d:\jenkins_sits\workspace\Mikz_UITests_Dev\Mikz.AutoTests.Publisher.UI\Program.fs:line 41
Seems like it happens only when the alert appears on the page? Any ideas how to handle this exception properly?
P.S. I have also found similar problem on stackoverflow. But I do not know how other screenshots are taken without problemn on the same remote machine.
The text was updated successfully, but these errors were encountered: