gemini-testing / gemini

💀💀💀[DEPRECATED] Use hermione
https://github.com/gemini-testing/hermione
MIT License
1.5k stars 149 forks source link

How to take fullpage screenshot #901

Closed cgaulay closed 6 years ago

cgaulay commented 6 years ago

Hi,

is there any way to capture the full page with gemini ? i've tried to do this but it doesn't work fine for me. There is just the viewport screen. thanks in advance. Regards,

Output of gemini --version: 5.6.2

Contents of .gemini.yml file:

rootUrl: http://XXXXX
gridUrl: http://localhost:4444/wd/hub
#windowSize: 1366x768
tolerance: 3.5
calibrate: false
httpTimeout: 5000
sessionRequestTimeout: 60000
sessionQuitTimeout: 5000
screenshotsDir: ./screens
screenshotDelay: 2000
browsers:
  firefox:
    desiredCapabilities:
      screenshotMode: fullpage
      browserName: firefox
      compositeImage: true
system:
  debug: true

Test source code:

gemini.suite('test', (suite) => {
    suite.setUrl('/')
        .setCaptureElements('body')
        .capture('plain');
});

Command used to run the test:

gemini update --reporter html test.js 

Result: There is just the viewport screen

Dmitriy-kiselyov commented 6 years ago

Hello! It seems like you misunderstand option screenshotDelay. Your page has some elements, that appear with time, so you want to wait for them to appear before taking a screenshot. You have 2 common ways to achieve that:

  1. use actions.waitForElementToShow(selector, [timeout]) function in your capture block if you are waiting for some particular element
  2. or use actions.wait(milliseconds) if there are many delayed elements Read more here

In you case I think you want to do something like this:

gemini.suite('test', (suite) => {
    suite.setUrl('/')
        .setCaptureElements('body')
        .capture('plain', (actions) => actions.wait(2000));
});

and remove screenshotDelay option.

This should fix your problem. Please report if it does and close issue.

P.S. About screenshotDelay. For example your body can be captured by 4 screenshots. So if you use screenshotDelay: 2000 then whole capture session will last for ≈8 seconds. But if you use actions.wait(2000), capture session will wait for 2 seconds and then perform 4 screenshots with no interval, so session will last ≈2 seconds

j0tunn commented 6 years ago

@cgaulay There are some errors in your config. Instead of this:

browsers:
  firefox:
    desiredCapabilities:
      screenshotMode: fullpage
      browserName: firefox
      compositeImage: true

you should write something like this:

browsers:
  firefox:
    screenshotMode: fullpage
    compositeImage: true
    desiredCapabilities:
      browserName: firefox

screenshotMode and compositeImage are the browser options and not the desired capabilities. In fact you can omit screenshotMode option, it does nothing in your case.

cgaulay commented 6 years ago

Hi all,

thanks a lot for your answers.

@Dmitriy-kiselyov, i've tried to add some wait options but it doesn't work much more.

@j0tunn, i've fixed my config and i've the same result :(

Any other ideas ?

Thanks. Regards,

Dmitriy-kiselyov commented 6 years ago

Hello! Can you please provide minimal-case html page with same error? And I will try to send you a config file and gemini test, which covers it. Or fix bugs if it is gemini's fault.

cgaulay commented 6 years ago

Hi @Dmitriy-kiselyov, thanks for your answser. I've tried to execute my test on another html page with the same configuration file. And it doesn't work much more but i've an error : "Out of the bound" (with chrome and firefox). However, during the test, Gemini seems to scroll on the page.This is not the same behavior than my html page.

But, to answser your question, you can try to take fullpage screenshot on this url : www.ouest-france.fr

Thanks in advance, Regards

generalov commented 6 years ago

Hey @Dmitriy-kiselyov , I've got the same issue in Chrome browser (Version 65.0.3325.146). I'd like to capture fullpage screenshot but it captures viewport only. Here is a minimal-case example https://github.com/generalov/gemini-demo .

Kenith commented 6 years ago

@cgaulay & @generalov try to set the viewport as following, and it should work: screenshotMode: 'viewport',

I don't know why need to set viewport and the full page captured. Wired why set fullpage not working...

For more, please refer to: Gemini_Chrome_SimulatePC&iPhone

cgaulay commented 6 years ago

Hi @Kenith,

it's doesn't work. When i set the screenshotMode with "viewport" it capture viewport only .. Thanks

Kenith commented 6 years ago

@cgaulay I am trying your script now. And will get back to you asap

Kenith commented 6 years ago

@cgaulay I don't change much, just make mainly move the compositeImage: true to the top. And it works!!

Please get all the data here: Gemini.zip

And I used the docker: https://github.com/Kenith/ta-visual-lib for testing. screen shot 2018-04-23 at 6 10 34 pm

generalov commented 6 years ago

Hi @Kenith, I've found a root cause of my issue. It is CSS rule html, body { height: 100%; } . So the both .setCaptureElements('html') and .setCaptureElements('body') brings to small capture area. The area is equal to size of viewport rather to size of document. Surprise! :) Unfortunately, the same CSS rule is at yandex.ru home page.

I added a tweak into before and got a screenshot of whole page.

before((actions) => {
   actions.executeJS(function() { document.documentElement.style.height = 'auto'; })
})
Kenith commented 6 years ago

@generalov Glad to hear that it is working! ;)

cgaulay commented 6 years ago

Hi all,

it works for me with the tweak and compositeImage: true.

Thanks @Kenith, @generalov and all others !