wswebcreation / protractor-image-comparison

npm-module to compare images with protractor
86 stars 38 forks source link

image comparison support for IE browser #57

Closed manikandanks2000 closed 5 years ago

manikandanks2000 commented 6 years ago

We notice that image comparison is working for chrome and not for IE browser.

Can you confirm IE browser support for your module

wswebcreation commented 6 years ago

Hi @manikandanks2000

It should work on IE11 and Edge, you can view the tests I'm executing here https://saucelabs.com/beta/tests/81516addac2b4b95ba2b82197848a6bf/commands#127, it's all open.

Can you maybe explain what's not working?

manikandanks2000 commented 6 years ago

I ran the tests with IE browser on two different windows machine and the error message it shows while using protractor image comaprison module is as below.

Also we are using IE with protractor for functional actions like click etc which is working currently.

   WebDriverError: Specified URL (www.napaconnect.com) is not valid.
   Build info: version: '3.11.0', revision: 'e59cfb3', time: '2018-03-11T20:33:15.31Z'
   System info: host: 'DC1408H2', ip: '10.5.220.168', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.8.0_161'
   Driver info: driver.version: unknown

   JavascriptError: Error executing JavaScript
   Build info: version: '3.11.0', revision: 'e59cfb3', time: '2018-03-11T20:33:15.31Z'
   System info: host: 'NAPAAUTOONL-01', ip: '10.13.8.68', os.name: 'Windows 10', os.arch: 'x86', os.version: '10.0', java.version: '1.8.0_171'
   Driver info: driver.version: unknown
manikandanks2000 commented 6 years ago

JavascriptError: Error executing JavaScript Build info: version: '3.11.0', revision: 'e59cfb3', time: '2018-03-11T20:33:15.31Z' System info: host: 'DC1408H2', ip: '192.168.56.1', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.8.0_161' Driver info: driver.version: unknown

wswebcreation commented 6 years ago

Tnx Can you provide a little bit more of info like

Tnx

manikandanks2000 commented 6 years ago

conf.file info

'use strict';
var getSpecsFrom_Xlsx = require('./././utilities/xlsx/getSpecsFromXlsx.js');
//var exceltojson = require('./xlsx/xlstojson.js');
const path = require('path');
const jsonReports = process.cwd() + '/reports/json';
const Reporter = require('././utilities/reporter.js');
const allure = require('cucumberjs-allure-reporter');
var replace = require('replace-in-file');
var { After, Status } = require('cucumber');

exports.config = {
  //To Run IE Standalone server should run parallely
  seleniumAddress: 'http://localhost:4444/wd/hub',
  seleniumArgs: ['-Dwebdriver.ie.driver=C:\\Users\\PCTR359514\\AppData\\Roaming\\npm\\node_modules\\protractor\\node_modules\\webdriver-manager\\selenium\\IEDriverServer.exe'],
  //'autoStartStopServer':true,

  After: function (testCase) {
    var world = this;
    if (testCase.result.status === Status.FAILED) {
      return webDriver.takeScreenshot()
        .then(function (screenShot) {
          // screenShot is a base-64 encoded PNG
          world.attach(screenShot, 'image/png');
        });
    }
  },

  onPrepare: function () {
    browser.ignoreSynchronization = true;
    const protractorImageComparison = require('protractor-image-comparison');
    browser.protractorImageComparison = new protractorImageComparison(
      {
        autoSaveBaseline: true,
        baselineFolder: './baseline/screenshots/',
        screenshotPath: './reports/screenshots/',

        disableCSSAnimation: true,
        nativeWebScreenshot: true,
        blockOutStatusBar: true,
        ignoreColors: true,
        ignoreAntialiasing: true,
        ignoreColors: true
      }
    );
  },

  params: {
    randomNumber: Math.floor(Math.random() * 90000) + 10000,
    rwId: '', version: '1.0.0.0', DBvalue: '',
    globalTimeout: 3000,
    database: 'none',      // 'oracle' or 'none'
    imageComparison: 'false',    //  'true' or 'false'
    ScreenShot: 'All',  // 'All' or 'Error'    
  },

  ignoreUncaughtExceptions: true,
  pageTimeout: 2000,
  //allScriptsTimeout: 500000,    
  framework: 'custom',
  specs: getSpecsFrom_Xlsx.getSpecsFromXlsx(),
  frameworkPath: './node_modules/protractor-cucumber-framework',

  capabilities: {
    'browserName': 'internet explorer',
    //'browserName': 'chrome',
    'platformName': 'windows',
    shardTestFiles: false,
    maxInstances: 1,
  },
  /*
 multiCapabilities : [
    {
      'browserName' : 'internet explorer',
      shardTestFiles: true,
      maxInstances:2,
      maxSessions: 2,  
      'ignoreProtectedModeSettings': true  
    }, {
      'browserName' : 'chrome',
      shardTestFiles: true,
      maxInstances:2, //same version of browser
      maxSessions: 2,  //Any browser and any version
      'ignoreProtectedModeSettings': true 
    }
 ],*/
//directConnect:true,

  cucumberOpts: {

    format: 'json:./reports/json/cucumber_report.json',
    require: [
      './features/step_definitions/*.js',
      './features/step_definitions/myHooks.js',
      '../support/*.js'
    ],
    tags: '(@AllureScenario or @CucumberScenario or @ProtractorScenario) and (not @DatabaseTest)',
    // @DatabaseTest scenario can be included when the username & password of DB have been configured in Support/database.js
    monochrome: true,
    strict: true,
    plugin: ['pretty'],
    tags: true

  },

  onComplete: function () {
    Reporter.createHTMLReport();

    replace.sync({
      files: 'reports//html//cucumber_reporter.html',
      from: 'Cucumberjs Report',
      to: 'NAPA Connect Automation Report ' + browser.params.version + '',
    });

  }
};

function newFunction() {
  return 'chrome';
}
manikandanks2000 commented 6 years ago

javscript step definition file info

var chai = require('chai');
var chaiAsPromised = require('chai-as-promised');
chai.use(chaiAsPromised);
var expect = chai.expect;
var {
  defineSupportCode
} = require('cucumber');
protractorImageComparison = require('protractor-image-comparison');
//const assert = require('assert');
//const AssertionError = require('assert').AssertionError;

var LoginPage = require('../../pages/LoginPage.js');
var GlobalData = require('../../json/Centralized/GlobalData.json');
var ScreenShot = require('../../utilities/ScreenshotCapture.js');
var Db = require('../../utilities/DatabaseUtility.js');
var pixelmatch = require('pixelmatch');
//var runRowId,n;
//var currentRowid = [];

defineSupportCode(({
                     Given,
                     When,
                     Then
                   }) => {
  Given(/^I Launch NapaConnect Application$/, {
    timeout: browser.params.globalTimeout
  }, function () {
    browser.waitForAngularEnabled(false);

    if (browser.params.baseURL != null) {
      LoginPage.navigateToURL(browser.params.baseURL);
    } else {
      LoginPage.navigateToURL(GlobalData[0].baseURL);
    }
    expect(browser.protractorImageComparison.checkScreen('I Launch NapaConnect Application'))
      .to
      .eventually
      .equal(0);

    //  const attach = this.attach;
    //  ScreenShot.attachScreenshot(attach);
    return browser.wait(function () {

    });
  });

  When(/^I enter login details$/, {
    timeout: browser.params.globalTimeout
  }, function () {
    console.log('entering login values....');
    if ((browser.params.username != null) && (browser.params.password != null)) {
      LoginPage.logindetails(browser.params.username, browser.params.password);
    } else {
      LoginPage.logindetails(GlobalData[0].username, GlobalData[0].password);
    }

    const attach = this.attach;
    ScreenShot.attachScreenshot(attach);
    if (browser.params.imageComparison = 'true') {
      assert(browser.protractorImageComparison.checkScreen('I enter login details'))
        .to
        .eventually
        .equal(0);
    }
    return browser.wait(function () {

    });

  });
  Then(/^I Should login to application$/, {
    timeout: browser.params.globalTimeout
  }, function () {

    const attach = this.attach;
    ScreenShot.attachScreenshot(attach);
    if (browser.params.imageComparison = 'true') {
      expect(browser.protractorImageComparison.checkScreen('I Should login to application'))
        .to
        .eventually
        .equal(0);
    }

    return browser.wait(function () {
      //    expect(browser.protractorImageComparison.checkScreen('I Should login to application')).to.eventually.equal(0);
      return expect(LoginPage.login);

    });
  });
});
manikandanks2000 commented 6 years ago

Again as stated earlier IE browser works for functional activities like browser.get etc .... it fails exactly at the functions calling image comparison

   JavascriptError: Error executing JavaScript
   Build info: version: '3.11.0', revision: 'e59cfb3', time: '2018-03-11T20:33:15.31Z'
   System info: host: 'DC1408H2', ip: '192.168.56.1', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.8.0_161'
   Driver info: driver.version: unknown
wswebcreation commented 6 years ago

Ok, tnx, can you also share your versions of protractor and cucumber?

Problem is that if I execute the tests on IE and don't see this behaviour

manikandanks2000 commented 6 years ago

protractor 5.3.1

manikandanks2000 commented 6 years ago

cucumber 1.3.0

manikandanks2000 commented 6 years ago

+-- UNMET PEER DEPENDENCY cucumber@>= 1.3.0 +-- cucumber-expressions@5.0.3 | -- becke-ch--regex--s0-0-v1--base--pl--lib@1.2.0 +-- cucumber-html-report@0.6.2 | +-- atob@2.0.3 | +-- moment@2.19.2 | +-- mustache@2.3.0 | +-- object-assign@4.1.1 |-- ramda@0.23.0 +-- cucumber-html-reporter@3.0.4 | +-- find@0.2.7 | | -- traverse-chain@0.1.0 | +-- fs-extra@3.0.1 extraneous | +-- js-base64@2.3.2 | +-- jsonfile@3.0.1 extraneous | +-- lodash@4.17.4 deduped |-- open@0.0.5

manikandanks2000 commented 6 years ago

can u confirm your npm/protractor details and the sample page which works for you currently ? i want to confirm the difference with my environment and your environment.

manikandanks2000 commented 6 years ago

also confirm the npm, protractor version ...

manikandanks2000 commented 6 years ago

One more update , i see its working for one application and its not working for another application. What are the known limitations of applications/technology with respect to IE browser.

wswebcreation commented 6 years ago

Sorry for the late update,

I use it with CucumerJS 2,3 and 4 with the latest version of Protractor. CucumberJS 1.3 is very old, but should not affect making the screenshot on IE 11

Based on your provided info I would suggest:

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.