Skip to content

Instantly share code, notes, and snippets.

@jaffamonkey
Created April 10, 2020 18:08
Show Gist options
  • Save jaffamonkey/bc708da9a7064097c3d01d3154f13497 to your computer and use it in GitHub Desktop.
Save jaffamonkey/bc708da9a7064097c3d01d3154f13497 to your computer and use it in GitHub Desktop.
// Filename: jest-webdriver.js
// To setup: npm install -g jest selenium-webdriver chromedriver
// To run: jest jest-webdriver.js
var webdriver = require('selenium-webdriver'),
By = webdriver.By;
var browser = new webdriver
.Builder()
.usingServer()
.withCapabilities({
'browserName': 'chrome',
'chromeOptions': {
args: ["headless", "disable-gpu"]
}
}).build();
describe('Check the DuckDuckGo search results page', function () {
it('Check the page title', async function () {
await browser.get('https://duckduckgo.com');
await browser.findElement(By.name('q')).sendKeys('TrumpKlon');
await browser.findElement(By.id('search_button_homepage')).click();
var title = await browser.getTitle();
expect(title).toEqual('TrumpKlon at DuckDuckGo');
var result = await browser.findElement(By.id('links')).getText();
expect(result).toMatch(/TrumpKlon/);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment