Name: cloudbreak-e2e-protractor
Owner: Hortonworks Inc
Description: Cloudbreak Web UI E2E test project (Protractor, Chai, Cucumber, TypeScript)
Created: 2017-09-12 09:28:52.0
Updated: 2017-11-22 10:33:27.0
Pushed: 2018-01-08 10:28:58.0
Size: 189
Language: TypeScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Please install followings if these have not installed for you:
You can check Protractor browser compatibility at Protractor Browser Support
IDE or Text Editor should be installed (WebStorm/Sublime/Visual Studio Code/Brackets)
Every variable from environment file should be present as environment variables with valid values:
For OS X Yosemite users with IntelliJ IDEA: You should add the environment variables to your
bash_profile
to can run tests directly form IDEA with no issues. The file should contain the variables for examples:
rt BASE_URL=your.url
chctl setenv BASE_URL $BASE_URL
rt USERNAME=your@mail.address
chctl setenv USERNAME $USERNAME
rt PASSWORD=your.password
chctl setenv PASSWORD $PASSWORD
tc.
Please do not forget you should reopen your project and restart your IDE.
If you do not want to create permanent environment variables on your machine, you can create a source file (for example environment
) instead:
rt BASE_URL=your.url
rt USERNAME=your@mail.address
rt PASSWORD=your.password
tc.
rt PATH=/<local path of the project>/cloud-e2e-protractor/node_modules/protractor/bin:$PATH
After these you can set all of these in one round with source
in current shell using:
d +x environment
vironment
or
d +x environment
ce environment
Set your local Node environment up (install every needed packages and tools) for the project. Run:
the root of the project where the `package.json` is located.
If your Protractor test environment has just cloned, you should set up its Node environment first (install every needed packages and tools). The easiest way to get all the needed Node packages in one round to use
yarn install
. Please check the yarn install documentation. Beyond these please check the Protractor Tutorial. You do not need to launch thewebdriver-manager
for these tests, because of thedirectConnect
istrue
by default in the Protractor configuration. In this case the Protractor works directly with Chrome or Firefox Driver, bypassing any Selenium Server.
test
Above command compiles the project then launches all the tests in the Browser based on the project configuration.
Protractor can test directly using Chrome Driver, bypassing any Selenium Server. The advantage of direct connect is that your test project start up and run faster.
To use this, you should change your config file:
ctConnect: true
If this is true, settings for seleniumAddress and seleniumServerJar will be ignored. If you attempt to use a browser other than Chrome or Firefox an error will be thrown.
“now possible to build up large test suites using this pattern. There are no additional packages required to create page objects. It turns out that
Object.create
provides all necessary features we need:
- inheritance between page objects
- lazy loading of elements and
- encapsulation of methods and actions
The goal behind page objects is to abstract any page information away from the actual tests. Ideally you should store all selectors or specific instructions that are unique for a certain page in a page object, so that you still can run your test after you?ve completely redesigned your page.” by WebDriverIO
rt { browser, $, by, element, protractor } from 'protractor'
rt class LoginPageObject {
public usernameBox: any = $("input[id='username']");
public passwordBox: any = $("input[id='password']");
public loginButton: any = element(by.cssContainingText('.btn.btn-primary','Login'));
login() {
...etc.
}
...etc.
“A page object wraps an HTML page, or fragment, with an application-specific API, allowing you to manipulate page elements without digging around in the HTML.” The basic rule of thumb:
- It should allow to do anything and see anything that a human can
- It should also provide an interface that's easy to access and modify
- It should hide the underlying widgetry
- It should have accessor methods that take and return your values and commands
- check boxes should use booleans
- buttons should be represented by action oriented method names
The page object should encapsulate the mechanics required to find and manipulate the data in the gui control itself.” by Martin Fowler
“From the structural side it makes sense to separate spec files and page objects and put them into different directories.“?“This is the basic principle of how to write page objects with WebdriverIO. Note that you can build up way more complex page object structures than this. For example have specific page objects for modals or split up a huge page object into different sections objects that inherit from the main page object. The pattern gives you really a lot of opportunities to encapsulate page information from your actual tests, which is important to keep your test suite structured and clear in times where the project and number of tests grows.” by WebDriverIO
?“all important selectors that are required in our page object as getter functions.“?” These functions get evaluated when you actually access the property and not when you generate the object. With that you always request the element before you do an action on it.” by WebDriverIO
“get: A function which serves as a getter for the property, or undefined if there is no getter. The function return will be used as the value of property.” by MDN
“Methods are actions that can be performed on objects. Object properties can be both primitive values, other objects, and functions. An object method is an object property containing a function definition.” by W3 Schools
“Properties are the most important part of any JavaScript object.“?“Properties are the values associated with a JavaScript object.“?“All properties have a name. In addition they also have a value. The value is one of the property's attributes. Other attributes are: enumerable, configurable, and writable.“?“In JavaScript, all attributes can be read, but only the value attribute can be changed (and only if the property is writable).” by W3 Schools
“value: Can be any valid JavaScript value (number, object, function, etc).” by MDN
Docker image for executing headless Google Chrome Protractor e2e test cases in Docker container.
The cloudbreak-web-e2e image is available here.
We created a very simple Makefile to be able build and run easily our Docker image:
run
or you can run the above commands in one round:
port BASE_URL=your.url
port USERNAME=your@mail.address
port PASSWORD=your.password
.etc.
ke build
run
cloud-e2e-runner
name of the new Docker container (created from hortonworks/cloudbreak-web-e2e
Docker image).utils/testenv
the location (full path) of the testenv
file on your machine.$(PWD)
or $pwd
the root folder of your Protractor test project.$(PWD)
.yarn test
launch tests.