Skip to content

Instantly share code, notes, and snippets.

Avatar

Marcel Mokoš marcelmokos

View GitHub Profile
@marcelmokos
marcelmokos / protractor-config.js
Last active Jan 3, 2017
protractor usage with non angular applications
View protractor-config.js
export const config = {
//...
onPrepare: function () {
/**
* If you are testing against a non-angular site - set ignoreSynchronization setting to true
*
* If true, Protractor will not attempt to synchronize with the page before
* performing actions. This can be harmful because Protractor will not wait
* until $timeouts and $http calls have been processed, which can cause
* tests to become flaky. This should be used only when necessary, such as
View .babelrc
{
"presets": [
"latest",
"stage-0"
]
}
@marcelmokos
marcelmokos / protractor-config.js
Created Jan 3, 2017
protractor-config.js with jasmine-spec-reporter
View protractor-config.js
//noinspection JSUnusedGlobalSymbols
import {SpecReporter} from "jasmine-spec-reporter";
export const config = {
framework: "jasmine2",
specs: ["spec/**/*.spec.js"],
directConnect: true,
chromeDriver: "node_modules/.bin/chromedriver",
jasmineNodeOpts: {
// remove ugly protractor dot reporter
@marcelmokos
marcelmokos / Homepage.spec.js
Created Jan 4, 2017
Page object pattern example
View Homepage.spec.js
import Homepage from "./pages/Homepage";
const homepage = new Homepage();
describe("homepage", () => {
describe("when on homepage", () => {
beforeAll(() => {
homepage.get();
});
@marcelmokos
marcelmokos / Homepage.spec.js
Created Jan 4, 2017
Page object pattern example
View Homepage.spec.js
import Homepage from "./pages/Homepage";
const homepage = new Homepage();
describe("homepage", () => {
describe("when on homepage", () => {
beforeAll(() => {
homepage.get();
});
@marcelmokos
marcelmokos / Homepage.js
Created Jan 4, 2017
Page object example
View Homepage.js
import Page from "../../utils/Page";
import Common from "./Common";
export default class Homepage extends Page {
selector = $("#page-main");
get = () => {
/**
* Browser window will maximize width and height
*/
@marcelmokos
marcelmokos / UIElement.js
Last active Jul 20, 2017
Example of Page object pattern base class
View UIElement.js
/**
* Base ui component class that other components should inherit from.
*/
export default class UIComponent {
/**
* This class property enables use of specific functions 'isDisplayed' and 'waitUntilDisplayed'
* @type {ElementFinder}
*/
selector = undefined;
@marcelmokos
marcelmokos / async.js
Last active Jan 5, 2017
Async await example
View async.js
/*-------- Promise.then() syntax ---------*/
/**
* @param inputElementWithLabel {ElementFinder}
* @returns {Promise.<ElementFinder>}
*/
export const getInputsLabelElement = (inputElementWithLabel) => {
inputElementWithLabel.getAttribute("id").then((inputId) => {
return $(`[for='${inputId}']`);
});
@marcelmokos
marcelmokos / asyncIt.js
Last active Dec 22, 2018
test two elements have same classes
View asyncIt.js
/*-------- Promise.then() syntax ---------*/
// when expect() is in Promise.then() method body
// we have to use callback function done()
it("test two inputs to have labels with same classes using Promise.then() ", (done) => {
getInputsLabelElement(input1).then((label1) => {
getInputsLabelElement(input2).then((label2) => {
label1.getAttribute("class").then((label1Classes) => {
label2.getAttribute("class").then((label2Classes) => {
expect(label1Classes).toBe(label2Classes);
View .editorconfig
# EditorConfig: http://EditorConfig.org
# EditorConfig Properties: https://github.com/editorconfig/editorconfig/wiki/EditorConfig-Properties
# top-most EditorConfig file
root = true
### defaults
[*]
charset = utf-8