Noksa / WebDriver.Screenshots.Extensions

C# WebDriver screenshots extensions, like a screenshot entire page
MIT License
12 stars 9 forks source link

some website can not take full screenshot #16

Closed nqbjnh closed 5 years ago

nqbjnh commented 5 years ago

Hi, Website: https://www.nordstromrack.com/ This website can not take full screenshot. I used ChromeDriver. Do you know where the problem is? please, help me. Thanks you

Noksa commented 5 years ago

Hello @nqbjnh I cant open this site to reproduce error. image

nqbjnh commented 5 years ago

This site allow ip address from USA.

Vào 19:25 T.3, 07 Th5 2019 Alexandr D. notifications@github.com đã viết:

Hello @nqbjnh https://github.com/nqbjnh I cant open this site to reproduce error. [image: image] https://user-images.githubusercontent.com/36312857/57299033-4c7eb880-70dc-11e9-8021-51191b6d0f8c.png

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Noksa/WebDriver.Screenshots.Extensions/issues/16#issuecomment-490057571, or mute the thread https://github.com/notifications/unsubscribe-auth/AGGY66ZZBYQLBU5DN543SNTPUFYLTANCNFSM4HK6LQDA .

Noksa commented 5 years ago

This is a bug.

nqbjnh commented 5 years ago

Thanks for fix, Have you updated on nuget yet?

Noksa commented 5 years ago

@nqbjnh Within an hour will be available.

Noksa commented 5 years ago

@nqbjnh Package is uploaded to nuget. Please check issue with new version and close it, if all are fine.

nqbjnh commented 5 years ago

Hi, I updated nuget, but i get a exception. Code: var imgByteArray = driver.TakeScreenshot(new VerticalCombineDecorator(new ScreenshotMaker()));

Exception: Script returned a value, but the result could not be cast to the desired type at OpenQA.Selenium.Support.Extensions.WebDriverExtensions.ExecuteJavaScript[T](IWebDriver driver, String script, Object[] args) at WDSE.Helpers.JQueryHelper.GetCurrentScrollLocation(IWebDriver driver, IWebElement element) at WDSE.Decorators.VerticalCombineDecorator.CombineScreenshots(IWebDriver driver) at WDSE.Decorators.VerticalCombineDecorator.MakeScreenshot(IWebDriver driver) at WDSE.ExtensionMethods.TakeScreenshot(IWebDriver driver, IScreenshotStrategy strategy) at UsExpress.Lib.AutomaticPurchases.Core.Utilities.WebDriverExtensions.TakeScreenShot(IWebDriver driver, String PathFileName) in G:\Projects\UsExpress\UsExpress_API\UsExpress.Lib.AutomaticPurchases.Core\Utilities\WebDriverExtensions.cs:line 150

Noksa commented 5 years ago

@nqbjnh on which site?

Same code worked on https://www.nordstromrack.com/ with 1920x1080 resolution.

Driver.Manage().Window.Size = new Size(1920, 1080);
Driver.Navigate().GoToUrl("https://www.nordstromrack.com/");
var screenMaker = new ScreenshotMaker();
var arr = Driver.TakeScreenshot(new VerticalCombineDecorator(screenMaker));

Chromedriver / chrome versions? Resolution of screen? Maximized browser?

nqbjnh commented 5 years ago

I copy your code, and i get error. error

What is version chromedriver, .NetFramework, Chrome you use?

Noksa commented 5 years ago

Chrome: Version 74.0.3729.131 (Official Build) (64-bit) Chromedriver is last, used by https://github.com/rosolko/WebDriverManager.Net .NET 4.7.1

PS: I'm upload beta with more logging and maybe fix your problem, try it please: https://www.nuget.org/packages/Noksa.WebDriver.ScreenshotsExtensions/0.1.4.1-beta

nqbjnh commented 5 years ago

I get beta version and get error Error: Input string was not in a correct format. at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) at WDSE.Helpers.JQueryHelper.GetCurrentScrollLocation(IWebDriver driver, IWebElement element) at WDSE.Decorators.VerticalCombineDecorator.CombineScreenshots(IWebDriver driver) at WDSE.Decorators.VerticalCombineDecorator.MakeScreenshot(IWebDriver driver) at WDSE.ExtensionMethods.TakeScreenshot(IWebDriver driver, IScreenshotStrategy strategy) at WinAppConfigChrome.Program.Main(String[] args) in G:\Projects\UsExpress\UsExpress_API\WinAppConfigChrome\Program.cs:line 39

I think this function WDSE.Helpers.JQueryHelper.GetCurrentScrollLocation error

Noksa commented 5 years ago

I changed the function a bit to use pure js instead of jquery and add TryParse instead of parse. Try it please: https://www.nuget.org/packages/Noksa.WebDriver.ScreenshotsExtensions/0.1.4.2-beta

nqbjnh commented 5 years ago

I updated 0.1.4.2-beta, but i get a error: Error: Cant get current scroll location: 2252.80004882813 at WDSE.Helpers.JQueryHelper.GetCurrentScrollLocation(IWebDriver driver, IWebElement element) at WDSE.Decorators.VerticalCombineDecorator.CombineScreenshots(IWebDriver driver) at WDSE.Decorators.VerticalCombineDecorator.MakeScreenshot(IWebDriver driver) at WDSE.ExtensionMethods.TakeScreenshot(IWebDriver driver, IScreenshotStrategy strategy) at WinAppConfigChrome.Program.Main(String[] args) in G:\Projects\UsExpress\UsExpress_API\WinAppConfigChrome\Program.cs:line 51

error

Noksa commented 5 years ago

Okay, thanks. Now I understand what the problem is. But i still dont understand how it's can be double, not int.

Noksa commented 5 years ago

@nqbjnh This version (https://www.nuget.org/packages/Noksa.WebDriver.ScreenshotsExtensions/0.1.4.3-beta) fixed this issue i guess. But this is still not the final version and, perhaps, the entire screenshot may not be correct with the offset of a pair of pixels. I'm need more time to investigate problem, when scrollTop returns not integer/long.

Noksa commented 5 years ago

@nqbjnh Can you give feedback? It works?

nqbjnh commented 5 years ago

Hi, It worked. Thanks you so much. error

Noksa commented 5 years ago

@nqbjnh Glad to hear that. :)

anvilnext commented 4 years ago

Hey. I don't understand how to save the screenshot on a disk.