gemini icon indicating copy to clipboard operation
gemini copied to clipboard

Is that possible to use screenshotMode: fullpage on ChromeDriver?

Open thybzi opened this issue 9 years ago • 20 comments

Trying to use Gemini via ChromeDriver for mobile emulation testing I want to get full page screenshot

My current settings are the following:

browsers:
  mobile-320:
    desiredCapabilities:
      browserName: chrome
      chromeOptions:
        mobileEmulation:
          userAgent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 8_0 like Mac OS X) AppleWebKit/600.1.3 (KHTML, like Gecko) Version/8.0 Mobile/12A4345d Safari/600.1.4'
          deviceMetrics:
            width: 320
            height: 6000
            pixelRatio: 1

This variant doesn't fail, though makes screenshots not 6000px high, but my available screen area high

I tried adding screenshotMode: fullpage, which doesn't have any effect.

Combining screenshotMode: fullpage with height: 568 (instead of 6000) leads to out of bounds exception.

Any idea how to make this work (and make fullscreen mobile screenshot)?

thybzi avatar Aug 22 '16 18:08 thybzi

I am capturing body element (html produces the same error)

Exception I'm getting:

StateError: Can not capture the specified region of the viewport.
            The region bottom bound is outside of the viewport height.
            Alternatively, you can test such cases by setting "true" value to option "compositeImage" in the config file.
            Element position: 0, 0; size: 320, 1611.
            Viewport size: 320, 568.

Setting compositeImage: true makes header with position fixed to duplicate on multiple positions, which is not good.

thybzi avatar Aug 22 '16 18:08 thybzi

in your case you can change position: fixed to position: static with executeJS to capture all body. But what state you need to check?

sipayRT avatar Aug 25 '16 08:08 sipayRT

I just want to capture the full page without header doubling :)

thybzi avatar Aug 25 '16 13:08 thybzi

Thanks for executeJS hack

But the true question is in issue's title:

Is that possible to use screenshotMode: fullpage on ChromeDriver?

thybzi avatar Aug 25 '16 13:08 thybzi

option screenshotMode is about working with page, it's not mean that you can get screenshot of the full page. To capture block that biggest than viewport sizes you should use compositeImage option

sipayRT avatar Aug 25 '16 14:08 sipayRT

UPD. "Out of bounds" exception is thrown even with both screenshotMode: fullpage and compositeImage: true set at the same time, if I use ChromeDriver.

When using PhantomJS with the same options enabled, no such error is produced.

Reproduced on Windows 10, but if you want, I'll try to reproduce on MacOSX/Ubuntu systems, too

thybzi avatar Aug 28 '16 17:08 thybzi

"Out of bounds" exception is thrown even with both screenshotMode: fullpage and compositeImage: true set at the same time, if I use ChromeDriver.

Can you show your screen sizes and Chrome version on which I can reproduce that behavior?

sipayRT avatar Aug 29 '16 09:08 sipayRT

Real screen size: 1920×1080 Gemini config screen size: 320×578 (set via deviceMetrics, or windowSize, or both) Chrome version: 52.0.2743.116 m ChromeDriver version: 2.23.409699 (49b0fa931cda1caad0ae15b7d1b68004acd05129) Gemini version: 4.6.0 Windows version: Windows 10 x64, version 1511, build 10586.545

thybzi avatar Sep 08 '16 17:09 thybzi

https://github.com/gemini-testing/gemini/pull/592

sipayRT avatar Sep 09 '16 16:09 sipayRT

You mean it's fixed in #592?

thybzi avatar Sep 21 '16 10:09 thybzi

it's about out of the bound only. Your case with fixed header can't be fixed by gemini

sipayRT avatar Sep 21 '16 10:09 sipayRT

Ok, I'll retest the issue with fresh version of gemini

thybzi avatar Sep 21 '16 12:09 thybzi

I’ve exactly the same issues as @thybzi described.

I’m using gemini v4.12.0 and still get the Out of bounds exception. Seems like #592 did not fix this problem. I’ve added some console.log statements here in order to see the actual numbers, here is what I got:

safeRect.left 0
safeRect.top 1136
safeRect.width 320
safeRect.height -304
imageSize.height 832
imageSize.width 1440
rect.width 320
rect.height 568
rect.top 1136
rect.left 0

As you can see safeRect.height is a negative number which probably causes the problem.

For my test case I have set screenshotMode to fullpage and compositeImage to true. I haven’t set window sizes explicitly but I’m also using the mobileEmulation feature of chromeDriver with the Apple iPhone 5 preset.

"desiredCapabilities": {
  "chromeOptions": { "mobileEmulation": { "deviceName": "Apple iPhone 5" } }
}

I’m testing against chrome 53.0 on Windows 10 with a native screen resolution of 1440x900 (via saucelabs). I’m capturing the body element.

lo1tuma avatar Oct 06 '16 10:10 lo1tuma

@lo1tuma can you provide test and page for testing to reproduce your problem?

sipayRT avatar Oct 06 '16 15:10 sipayRT

@sipayRT sure, I pushed a reproducible test case here: https://github.com/lo1tuma/gemini-issue-557

lo1tuma avatar Oct 06 '16 17:10 lo1tuma

@eGavr ⬆️ tvoj lubimij "out of the bounds" :)

sipayRT avatar Oct 10 '16 11:10 sipayRT

@sipayRT , кажется, что для out of the bounds стоит завести отдельный issue, нет?

eGavr avatar Oct 10 '16 12:10 eGavr

Will be great to fix this and out of the bounds issues. Any updates here?

pftg avatar Nov 08 '16 12:11 pftg

Currently having the same Problem with current versions of Chrome, Selenium and Gemini. Maybe this is related to Chromedriver Issue 294?

mchennig avatar Dec 04 '18 20:12 mchennig

Having the same issues.

But actually I'm luvky when I get "out of bounds". I've been experiencing all kinds of issues includung various failures to "inject" (?) Gemini code into th page etc.

masi avatar Mar 29 '19 18:03 masi