Skip to content
Merged
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
32 changes: 20 additions & 12 deletions examples/jest/puppeteer.test.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,31 @@
const puppeteer = require('puppeteer-core');

const TB_KEY = process.env.TB_KEY || 'Your TestingBot Key';
const TB_SECRET = process.env.TB_SECRET || 'Your TestingBot Secret';
const capabilities = {
'tb:options': {
key: process.env.TB_KEY,
secret: process.env.TB_SECRET,
name: 'Jest-Puppeteer-Example'
},
browserName: 'chrome',
browserVersion: 'latest',
platform: 'WIN10'
};

let browser;
let page;

beforeAll(async () => {
browser = await puppeteer.connect({
browserWSEndpoint: `wss://${TB_KEY}:${TB_SECRET}@cloud.testingbot.com/puppeteer?browserName=chrome&browserVersion=latest&platform=WIN10&name=Jest-Puppeteer-Example&screenRecorder=true`
browserWSEndpoint: `wss://cloud.testingbot.com/puppeteer?capabilities=${encodeURIComponent(JSON.stringify(capabilities))}`
});
page = await browser.newPage();
await page.setViewport({ width: 1366, height: 768 });
});

afterAll(async () => {
await browser.close();
if (browser) {
await browser.close();
}
});

test('TestingBot homepage title should be correct', async () => {
Expand All @@ -25,20 +35,18 @@ test('TestingBot homepage title should be correct', async () => {
}, 30000);

test('TestingBot logo should be visible', async () => {
await page.waitForSelector('.navbar-brand');
await page.waitForSelector('.navigation span');
const logoText = await page.evaluate(() => {
return document.querySelector('.navbar-brand').innerText;
return document.querySelector('.navigation span').innerText;
});
expect(logoText).toContain('TestingBot');
}, 10000);

test('TestingBot features section should exist', async () => {
const featuresExist = await page.evaluate(() => {
return document.querySelectorAll('.features').length > 0;
});
expect(featuresExist).toBe(true);
test('TestingBot navigation should link to the features page', async () => {
const featuresLinks = await page.$$('a[href="/features"]');
expect(featuresLinks.length).toBeGreaterThan(0);
}, 10000);

test('Take a screenshot', async () => {
await page.screenshot({ path: 'testingbot-jest.png' });
}, 5000);
}, 5000);
13 changes: 6 additions & 7 deletions examples/webdriverio/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,16 @@ describe('TestingBot Website', () => {
});

it('should display the TestingBot logo', async () => {
await $('.navbar-brand').waitForExist();
const logoText = await $('.navbar-brand').getText();
await expect(logoText).toContain('TestingBot');
const logo = await $('.navigation span');
await logo.waitForExist();
await expect(logo).toHaveText(expect.stringContaining('TestingBot'));
});

it('should have a features section', async () => {
const featuresSection = await $('.features');
await expect(featuresSection).toExist();
it('should link to the features page', async () => {
await expect($('a[href="/features"]')).toExist();
});

it('should take a screenshot', async () => {
await browser.saveScreenshot('testingbot-webdriverio.png');
});
});
});
3 changes: 2 additions & 1 deletion examples/webdriverio/wdio.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ exports.config = {
user: TB_KEY,
key: TB_SECRET,

// Spec paths are resolved relative to this config file
specs: [
'./examples/webdriverio/test.js'
'./test.js'
],

maxInstances: 1,
Expand Down
Loading
Loading