Skip to content
This repository was archived by the owner on Jan 31, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/eyes.selenium/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
},
"devDependencies": {
"@types/node": "*",
"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
"chromedriver": "^78.0.0",
"mocha": "^6.2.2",
"protractor": "^5.4.2",
Expand All @@ -65,6 +67,7 @@
"test:appium": "mocha --no-timeouts \"test/e2e/appium/**/*.js\"",
"test:selenium": "mocha --no-timeouts \"test/e2e/selenium/**/*.js\"",
"test:protractor": "protractor test/e2e/protractor/protractor.conf.js",
"test:coverage:custom": "mocha --no-timeouts \"test/coverage/custom/*.spec.js\"",
"typings": "tsc --declaration"
},
"license": "SEE LICENSE IN LICENSE",
Expand Down
120 changes: 120 additions & 0 deletions packages/eyes.selenium/test/coverage/custom/TestAbort.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
'use strict';
const {getDriver, getEyes, batch} = require('./util/TestSetup');
const chai = require('chai');
const chaiAsPromised = require('chai-as-promised');
chai.use(chaiAsPromised);
const expect = chai.expect;
const {
Target,
StitchMode,
} = require('../../../index');
const appName = 'My application';
const testedUrl = 'https://applitools.com/docs/topics/overview.html';
const testName = `test URL : ${testedUrl}`;

describe(appName, () => {

let webDriver, eyes;

afterEach(async () => {
if (eyes.getIsOpen()) {
await eyes.close(false)
} else {
await eyes.abort()
}
await webDriver.quit()
});
describe(`TestAbort`, () => {

beforeEach(async () => {
eyes = await getEyes(StitchMode.CSS);
eyes.setBatch(batch);
webDriver = await getDriver('CHROME');
});

it(`Test_ThrowBeforeOpen`, async () => {
expect(Test_ThrowBeforeOpen).to.throw('Before Open');

function Test_ThrowBeforeOpen() {
throw new Error('Before Open')
}
});

it(`Test_ThrowAfterOpen`, async () => {
await expect(Test_ThrowAfterOpen()).to.be.rejectedWith(Error, 'After Open');

async function Test_ThrowAfterOpen() {
await eyes.open(webDriver, appName, testName);
throw new Error('After Open')
}
});

it(`Test_ThrowDuringCheck`, async () => {
await expect(Test_ThrowDuringCheck()).to.be.rejectedWith(Error);

async function Test_ThrowDuringCheck() {
let driver = await eyes.open(webDriver, appName, testName);
await driver.get(testedUrl);
await eyes.check(`Step 1 Content - ${testedUrl}`, Target.frame('non-existing frame'))
}
});

it(`Test_ThrowAfterCheck`, async () => {
await expect(Test_ThrowAfterCheck()).to.be.rejectedWith(Error, 'After Check');

async function Test_ThrowAfterCheck() {
let driver = await eyes.open(webDriver, appName, testName);
await driver.get(testedUrl);
await eyes.check(`Step 1 Content - ${testedUrl}`, Target.window());
throw new Error('After Check')
}
})
});

describe.skip(`TestAbort_VG`, () => {
// Skipped as there is no Visual grid runner in the SDK
beforeEach(async () => {
eyes = await getEyes();
eyes.setBatch(batch);
webDriver = await getDriver('CHROME');
});

it(`Test_ThrowBeforeOpen`, async () => {
expect(Test_ThrowBeforeOpen).to.throw('Before Open');

function Test_ThrowBeforeOpen() {
throw new Error('Before Open')
}
});

it(`Test_ThrowAfterOpen`, async () => {
await expect(Test_ThrowAfterOpen()).to.be.rejectedWith(Error, 'After Open');

async function Test_ThrowAfterOpen() {
await eyes.open(webDriver, appName, testName);
throw new Error('After Open')
}
});

it(`Test_ThrowDuringCheck`, async () => {
await expect(Test_ThrowDuringCheck()).to.be.rejectedWith(Error);

async function Test_ThrowDuringCheck() {
let driver = await eyes.open(webDriver, appName, testName);
await driver.get(testedUrl);
await eyes.check(`Step 1 Content - ${testedUrl}`, Target.frame('non-existing frame'))
}
});

it(`Test_ThrowAfterCheck`, async () => {
await expect(Test_ThrowAfterCheck()).to.be.rejectedWith(Error, 'After Check');

async function Test_ThrowAfterCheck() {
let driver = await eyes.open(webDriver, appName, testName);
await driver.get(testedUrl);
await eyes.check(`Step 1 Content - ${testedUrl}`, Target.window());
throw new Error('After Check')
}
})
})
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
'use strict';
const {Eyes, Target} = require('../../../index');
const {Builder} = require('selenium-webdriver');
const {sauceUrl, batch} = require('./util/TestSetup');
const appiumUrl = 'http://localhost:4723/wd/hub';
const sauceCaps = {
browserName: '',
platformName: 'Android',
platformVersion: '8.1',
deviceName: 'Samsung Galaxy S9 WQHD GoogleAPI Emulator',
deviceOrientation: 'portrait',
username: process.env.SAUCE_USERNAME,
accessKey: process.env.SAUCE_ACCESS_KEY,
app: 'http://appium.s3.amazonaws.com/ContactManager.apk',
};

const caps = {
browserName: '',
deviceName: 'Nexus 5',
platformName: 'Android',
platformVersion: '8.0',
app: 'http://appium.s3.amazonaws.com/ContactManager.apk',
};

describe('TestAppiumNative', () => {
let driver, eyes;

afterEach(async () => {
await driver.quit();
await eyes.abortIfNotClosed()
});

it(`Native app on sauce lab`, async () => {
driver = await new Builder()
.withCapabilities(sauceCaps)
.usingServer(sauceUrl)
.build();
eyes = new Eyes();
eyes.setBatch(batch);
await eyes.open(driver, 'JS test', 'Checking eyes settings in appium tests');
await eyes.check(
'Check',
Target.window()
.ignore({left:900, top:0, width:540, height:100})
.fully(),
);
await eyes.close()
});

it(`Native app on local appium`, async () => {
driver = await new Builder()
.withCapabilities(caps)
.usingServer(appiumUrl)
.build();
eyes = new Eyes();
eyes.setBatch(batch);
await eyes.open(driver, 'JS test', 'Checking eyes settings in appium tests_local');
await eyes.check(
'Check',
Target.window()
.ignore({left:900, top:0, width:180, height:100})
.fully(),
);
await eyes.close()
})
});
85 changes: 85 additions & 0 deletions packages/eyes.selenium/test/coverage/custom/TestCount.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
'use strict';
const assert = require('assert');
const {Target} = require('../../../index');
const Configuration = () => {
}; // Need to be implemented for tests
const {getDriver, getEyes, batch} = require('./util/TestSetup');

describe.skip('TestCounts', () => {
// VG runner isn't implemented for the SDK
let driver, eyes;
beforeEach(async () => {
driver = await getDriver('CHROME');
await driver.get('https://applitools.com/helloworld');
eyes = await getEyes()
// need to set sendDom value (not implemented)
});

it('Test_VGTestsCount_1', async () => {
await eyes.setBatch(batch);
await eyes.setBranchName('master');
await eyes.open(driver, 'Test Count', 'Test_VGTestsCount_1', {width: 640, height: 480});
await eyes.check('Test', Target.window());
let results = await eyes.close();
assert.deepStrictEqual(1, results.getAllResults().length)
});

it('Test_VGTestsCount_2', async () => {
let conf = new Configuration();
conf.setBatch(batch);
conf.addBrowser(900, 600);
conf.addBrowser(1024, 768);
conf.setBranchName('master');
eyes.setConfiguration(conf);
await eyes.open(driver, 'Test Count', 'Test_VGTestsCount_2');
await eyes.check('Test', Target.window());
let results = await eyes.close();
assert.deepStrictEqual(2, results.getAllResults().length)
});

it('Test_VGTestsCount_3', async () => {
let conf = new Configuration();
conf.setBatch(batch);
conf.addBrowser(900, 600);
conf.addBrowser(1024, 768);
conf.setAppName('Test Count');
conf.setTestName('Test_VGTestsCount_3');
conf.setBranchName('master');
eyes.setConfiguration(conf);
await eyes.open(driver);
await eyes.check('Test', Target.window());
let results = await eyes.close();
assert.deepStrictEqual(2, results.getAllResults().length)
});

it('Test_VGTestsCount_4', async () => {
let conf = new Configuration();
conf.setBatch(batch);
conf.setAppName('Test Count');
conf.setTestName('Test_VGTestsCount_4');
conf.setBranchName('master');
eyes.setConfiguration(conf);
await eyes.open(driver);
await eyes.check('Test', Target.window());
let results = await eyes.close();
assert.deepStrictEqual(1, results.getAllResults().length)
});

it('Test_VGTestsCount_5', async () => {
let conf = new Configuration();
conf.setBatch(batch);
conf.addBrowser(900, 600);
conf.addBrowser(1024, 768);
conf.setBranchName('master');
eyes.setConfiguration(conf);
await eyes.open(driver, 'Test Count', 'Test_VGTestsCount_5', {width: 640, height: 480});
await eyes.check('Test', Target.window());
let results = await eyes.close();
assert.deepStrictEqual(2, results.getAllResults().length)
});

afterEach(async () => {
await driver.quit();
await eyes.abortIfNotClosed();
})
});
Loading