Skip to content

Instantly share code, notes, and snippets.

View marcelmokos's full-sized avatar

Marcel Mokoš marcelmokos

View GitHub Profile
@marcelmokos
marcelmokos / protractor-config.js
Last active January 3, 2017 23:09
protractor usage with non angular applications
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
@marcelmokos
marcelmokos / .babelrc
Last active February 9, 2017 22:30
.babelrc
{
"presets": [
"latest",
"stage-0"
]
}
@marcelmokos
marcelmokos / protractor-config.js
Created January 3, 2017 23:27
protractor-config.js with jasmine-spec-reporter
//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 January 4, 2017 02:01
Page object pattern example
import Homepage from "./pages/Homepage";
const homepage = new Homepage();
describe("homepage", () => {
describe("when on homepage", () => {
beforeAll(() => {
homepage.get();
});
@marcelmokos
marcelmokos / Homepage.spec.js
Created January 4, 2017 02:01
Page object pattern example
import Homepage from "./pages/Homepage";
const homepage = new Homepage();
describe("homepage", () => {
describe("when on homepage", () => {
beforeAll(() => {
homepage.get();
});
@marcelmokos
marcelmokos / Homepage.js
Created January 4, 2017 02:05
Page object example
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 July 20, 2017 21:09
Example of Page object pattern base class
/**
* 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 January 5, 2017 21:04
Async await example
/*-------- 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 December 22, 2018 22:00
test two elements have same classes
/*-------- 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);
# EditorConfig: http://EditorConfig.org
# EditorConfig Properties: https://github.com/editorconfig/editorconfig/wiki/EditorConfig-Properties
# top-most EditorConfig file
root = true
### defaults
[*]
charset = utf-8