applitools / Eyes.Selenium.JavaScript

Applitools Eyes SDK For Selenium JavaScript WebDriver
Other
18 stars 18 forks source link

eyes.selenium not working with Chrome builder #68

Closed marcellino-ornelas closed 5 years ago

marcellino-ornelas commented 5 years ago

Hey applitools I came accross a problem with the chrome builder. This is my code and I included the error message from from jest when i try running my test. It throws a error about the viewport size. Can someone help me out?

    /*
     Using 
      selenium-webdriver: 3.6.0
        Note: Anything ^4.0.0 causes error with eyes.selenium because of error with 
                  controlFlow not being defined
      eyes.selenium: 0.0.79
    */

    import 'selenium-webdriver/chrome';
    import 'selenium-webdriver/firefox';
    import 'chromedriver';
    import 'geckodriver';

    const webdriver = require('selenium-webdriver');
    const SeleniumSDK = require('eyes.selenium');

    jest.setTimeout(30000);

    const Capabilities = webdriver.Capabilities;
    const Builder = webdriver.Builder;
    const By = webdriver.By;

    const Eyes = SeleniumSDK.Eyes;

    // Open a Chrome browser.
    const driver = new Builder().withCapabilities(Capabilities.chrome()).build();

    const eyes = new Eyes();
    eyes.setApiKey('my-api-key');

    // scroll the entire page
    eyes.setForceFullPageScreenshot(true);

      /* Need async and wait for promises. Without this it times out and creates weird behaviors */
    test('run visual test',  async done => {
        // Start the test and set the browser's viewport size to 600 x 800
        await eyes.open(driver, 'Test app', 'First test', {
            width: 600,
            height: 800
        });

        console.log('eyes open');

        // Navigate the browser to the demo app
        await driver.get('http://localhost:8080');
        console.log('openned localhost');

        // Visual checkpoint #1.
        await eyes.checkWindow('Login Window test');
       /* Never passes this line right here*/
       console.log('performed first check window');

        await driver.click('login');
        console.log('driver clicked');

        await eyes.checkWindow('Login Window Error');
        console.log('performed second check window');

        await eyes.close(false);
        console.log('closed eyes');

        done();
    });

    afterAll(async () => {
        // Close the browser.
        await driver.quit();
        // If the test was aborted before eyes.close was called ends the test as aborted.
        await eyes.abortIfNotClosed();
    });

Here is the error message I get

 Error message:
========================================
  FAIL  tests/visual.test.js (9.672s)
      ● Console
        console.log tests/visual.test.js:41
          eyes open
        console.log tests/visual.test.js:52
          openned localhost

      ● run visual test

        Error
            Failed to set viewport size! thrown
astappiev commented 5 years ago

Hi @marcellino-ornelas,

Can you please provide your display size?

Thanks

marcellino-ornelas commented 5 years ago

Hey @astappiev,

what do you mean by display size? like the size of my computer?

astappiev commented 5 years ago

Yes, your screen resolution and pixel ratio, if possible. The easiest way to get them, just use this website https://www.piliapp.com/what-is-my/screen-resolution/

marcellino-ornelas commented 5 years ago

screen resolution: 2880x1800

window.devicePixelRatio: 2

astappiev commented 5 years ago

Can you try with a smaller height, like 600px?

Also, can you add eyes.setLogHandler(new ConsoleLogHandler(false)); and share logs?

marcellino-ornelas commented 5 years ago

ConsoleLogHandler? What package is this constructor coming from?

astappiev commented 5 years ago

Same as for Eyes constructor: var ConsoleLogHandler = SeleniumSDK.ConsoleLogHandler;