initial commit
This commit is contained in:
commit
b6f06585c1
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
.vscode/
|
||||
**/node_modules/
|
14
autotest.js
Normal file
14
autotest.js
Normal file
@ -0,0 +1,14 @@
|
||||
var webdriver = require('selenium-webdriver');
|
||||
|
||||
var browser_name = new webdriver.Builder();
|
||||
withCapabilities(webdriver.Capabilities.firefox()).build();
|
||||
|
||||
browser.get('http:/www.google.com');
|
||||
|
||||
var promise = browser_name.getTitle();
|
||||
|
||||
promise.then(function(title)
|
||||
{
|
||||
console.log(title);
|
||||
});
|
||||
browser.quit();
|
12
first_test.js
Normal file
12
first_test.js
Normal file
@ -0,0 +1,12 @@
|
||||
var webdriver = require('selenium-webdriver')
|
||||
|
||||
var browser = new webdriver.Builder().
|
||||
withCapabilities(webdriver.Capabilities.firefox()).build();
|
||||
|
||||
browser.get("http://www.google.com/");
|
||||
var promise = browser.getTitle();
|
||||
promise.then(function(title) {
|
||||
console.log(title);
|
||||
});
|
||||
|
||||
browser.quit();
|
76
jest.config.js
Normal file
76
jest.config.js
Normal file
@ -0,0 +1,76 @@
|
||||
module.exports = {
|
||||
automock: false,
|
||||
bail: false,
|
||||
//browser: false,
|
||||
cacheDirectory: "/var/cache/jest_dx",
|
||||
clearMocks: true,
|
||||
collectCoverage: false,
|
||||
moduleFileExtensions: [
|
||||
"js",
|
||||
"json",
|
||||
"jsx",
|
||||
"node"
|
||||
],
|
||||
notifyMode: "always",
|
||||
//preset: null,
|
||||
//projects: null,
|
||||
//reporters: undefined,
|
||||
resetMocks: false,
|
||||
resetModules: false,
|
||||
//resolver: null,
|
||||
runner: "jest-runner",
|
||||
setupFiles: [],
|
||||
//setupFilesAfterEnv: null,
|
||||
snapshotSerializers: [],
|
||||
testResultsProcessor: null,
|
||||
testRunner: "jasmine2",
|
||||
testURL: "http://localhost",
|
||||
timers: "real",
|
||||
transform: null,
|
||||
transformIgnorePatterns: [
|
||||
"/node_modules/"
|
||||
],
|
||||
moduleNameMapper: {},
|
||||
modulePathIgnorePatterns: [],
|
||||
notify: false,
|
||||
testEnvironment: "jest-environment-jsdom",
|
||||
testEnvironmentOptions: {},
|
||||
testLocationInResults: false,
|
||||
testMatch: [
|
||||
"**/jest_tests/**/*.js?(x)",
|
||||
"**/?(*.)+(spec|test).js?(x)"
|
||||
],
|
||||
testPathIgnorePatterns: [
|
||||
"/node_modules/"
|
||||
],
|
||||
testRegex: "",
|
||||
restoreMocks: false,
|
||||
rootDir: null,
|
||||
roots: [
|
||||
"<rootDir>"
|
||||
],
|
||||
//collectCoverageFrom: null,
|
||||
coverageDirectory: 'coverage',
|
||||
coveragePathIgnorePatterns: [
|
||||
"/node_modules/"
|
||||
],
|
||||
coverageReporters: [
|
||||
"json",
|
||||
"text",
|
||||
"lcov",
|
||||
"clover"
|
||||
],
|
||||
coverageThreshold: null,
|
||||
//errorOnDeprecated: false,
|
||||
forceCoverageMatch: [],
|
||||
globalSetup: null,
|
||||
globalTeardown: null,
|
||||
globals: {},
|
||||
moduleDirectories: [
|
||||
"node_modules"
|
||||
],
|
||||
//unmockedModulePathPatterns: undefined,
|
||||
verbose: true,
|
||||
watchPathIgnorePatterns: [],
|
||||
watchman: true,
|
||||
};
|
61
jest_tests/single_test.js
Normal file
61
jest_tests/single_test.js
Normal file
@ -0,0 +1,61 @@
|
||||
//single_test.js:Jest testing tutorial for Selenium JavaScript Testing
|
||||
/**
|
||||
* @jest-environment jest-environment-webdriver
|
||||
*/
|
||||
const webdriver = require('selenium-webdriver');
|
||||
const script = require('jest');
|
||||
const url = 'https://www.selenium.dev/'
|
||||
|
||||
const getElementXpath = async (driver, xpath, timeout = 3000) => {
|
||||
const el = await driver.wait(until.elementLocated(By.xpath(xpath)), timeout);
|
||||
return await driver.wait(until.elementIsVisible(el), timeout);
|
||||
};
|
||||
const getElementName = async (driver, name, timeout = 3000) => {
|
||||
const el = await driver.wait(until.elementLocated(By.name(name)), timeout);
|
||||
return await driver.wait(until.elementIsVisible(el), timeout);
|
||||
};
|
||||
const getElementId = async (driver, id, timeout = 3000) => {
|
||||
const el = await driver.wait(until.elementLocated(By.id(id)), timeout);
|
||||
return await driver.wait(until.elementIsVisible(el), timeout);
|
||||
};
|
||||
describe('executing test scenario on the website www.selenium.dev', async () => {
|
||||
let driver;
|
||||
driver = new webdriver().build();
|
||||
await driver.get(
|
||||
'https://www.selenium.dev',
|
||||
);
|
||||
}, 10000);
|
||||
|
||||
|
||||
afterAll(async () => {
|
||||
await driver.quit();
|
||||
}, 15000);
|
||||
|
||||
|
||||
test('it performs a validation of title on the home page', async () => {
|
||||
await browser.get(url)
|
||||
const title = await browser.findElement(by.tagName('h1')).getText()
|
||||
expect(title).toContain('SeleniumHQ Browser Automation')
|
||||
}),
|
||||
|
||||
test('it performs a validation of the search box on the page', async () => {
|
||||
const foundAndLoadedCheck = async () => {
|
||||
await until.elementLocated(by.id('search'))
|
||||
const value = await browser.findElement(by.id('search')).getText()
|
||||
return value !== '~'
|
||||
}
|
||||
await browser.wait(foundAndLoadedCheck, 3000)
|
||||
const search = await browser.findElement(by.id('search')).getText()
|
||||
expect(search).toEqual('')
|
||||
})
|
||||
|
||||
describe('it captures a screenshot of the current page on the browser', () => {
|
||||
|
||||
test('snap a picture by taking the screenshot', async () => {
|
||||
// files saved in ./reports/screenshots by default
|
||||
await browser.get(url)
|
||||
await browser.takeScreenshot()
|
||||
})
|
||||
})
|
||||
|
||||
|
42
mocha_tests/mocha_test.js
Normal file
42
mocha_tests/mocha_test.js
Normal file
@ -0,0 +1,42 @@
|
||||
var assert = require('assert');
|
||||
var webdriver = require('selenium-webdriver')
|
||||
var test = require('selenium-webdriver/test');
|
||||
var firefox = require('selenium-webdriver/firefox');
|
||||
|
||||
var driver;
|
||||
|
||||
test.describe('Google search', function() {
|
||||
|
||||
test.beforeEach(function(done) {
|
||||
this.timeout(5000);
|
||||
driver = new webdriver.Builder().
|
||||
withCapabilities(webdriver.Capabilities.firefox()).build();
|
||||
driver.get('https://google.com');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
test.afterEach(function(done) {
|
||||
driver.quit();
|
||||
done();
|
||||
});
|
||||
|
||||
test.it('webpage should have expected title value', function(done) {
|
||||
var promise = driver.getTitle();
|
||||
promise.then(function(title) {
|
||||
assert.equal(title, 'Google');
|
||||
});
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
test.it('Searchbox should have expected text', function(done) {
|
||||
var searchBox = driver.findElement(webdriver.By.name('q'));
|
||||
searchBox.sendKeys('random text');
|
||||
searchBox.getAttribute('value').then(function(value) {
|
||||
assert.equal(value, 'random text');
|
||||
});
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
7405
package-lock.json
generated
Normal file
7405
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
45
package.json
Normal file
45
package.json
Normal file
@ -0,0 +1,45 @@
|
||||
{
|
||||
"name": "jsdemo",
|
||||
"version": "1.0.0",
|
||||
"description": "just testing selenium-webdriver",
|
||||
"main": "autotest.js",
|
||||
"scripts": {
|
||||
"test": "jest"
|
||||
},
|
||||
"author": "Greg Gauthier",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"chai": "^4.2.0",
|
||||
"selenium-webdriver": "^4.0.0-alpha.7"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-eslint": "^10.0.1",
|
||||
"babel-jest": "^22.4.3",
|
||||
"babel-plugin-external-helpers": "^6.22.0",
|
||||
"babel-plugin-transform-object-rest-spread": "^6.26.0",
|
||||
"babel-preset-env": "^1.7.0",
|
||||
"chromedriver": "^74.0.0",
|
||||
"eslint": "^5.16.0",
|
||||
"eslint-config-airbnb-base": "^13.1.0",
|
||||
"eslint-config-prettier": "^4.3.0",
|
||||
"eslint-plugin-import": "^2.17.3",
|
||||
"eslint-plugin-jest": "^22.6.4",
|
||||
"eslint-plugin-prettier": "^3.1.0",
|
||||
"jasmin": "0.0.2",
|
||||
"jasmine": "^3.4.0",
|
||||
"jest": "^22.4.4",
|
||||
"jest-environment-webdriver": "^0.2.0",
|
||||
"jsdom": "^15.1.1",
|
||||
"prettier": "^1.17.1",
|
||||
"rimraf": "^2.6.3",
|
||||
"selenium-webdriver": "^4.0.0-alpha.1"
|
||||
},
|
||||
"jest": {
|
||||
"setupTestFrameworkScriptFile": "./jest.config.js",
|
||||
"testEnvironment": "jest-environment-webdriver",
|
||||
"testEnvironmentOptions": {
|
||||
"browser": "chrome"
|
||||
}
|
||||
},
|
||||
"keywords": []
|
||||
}
|
Loading…
Reference in New Issue
Block a user