carmation-next-framework v0.0.17
Using the Carmation-Framework
Install node js
download here https://nodejs.org/en/download/
Install Java 8
download here https://www.java.com/en/download/
download here
Install all dependencies
npm i
Example project To be created
Carmation-next-framework
An E-2-E solution for FE and BE automation using Jest, Puppeteer, Superagent and Chai.
Table of Contents
- How does it work?(How does it work?)
How does it work?
Carmation-next-framework uses Puppeteer to interact with Chrome, which can be run headed. It follows the strategie pattern and consists of three principles:
- Browser(desktop, mobile, tablet)
- Element(WebElement, Locator, WebElementProvider)
- Interactions(action)
A basic setup would look like this
- src/
- specs(tests)
- pageObjects(elements)
- actions(elementInteractions)
Install
$ npm i carmation-next-framework --save-dev
Setup a new project
Create a folder
$ mkdir exampleProject
Start a project
$ npm init
Open the package.json and update:"
{
"name": "exampleproject",
"version": "1.0.0",
"description": "this is an example project",
"main": "index.js",
"scripts": {
"test": "jest",
"report:gen": "npx allure generate --clean",
"report:open": "npx allure open"
},
"author": "",
"license": "ISC",
"devDependencies": {
"@types/jest": "^25.2.1",
"allure-commandline": "^2.13.0",
"carmation-next-framework": "^0.0.10",
"jest": "^26.0.1",
"jest-allure": "^0.1.3",
"puppeteer": "^3.3.0",
"ts-jest": "^26.1.0",
"ts-node": "^8.10.2",
"typescript": "^3.9.5"
},
"jest": {
"clearMocks": true,
"moduleFileExtensions": [
"js",
"ts"
],
"preset": "ts-jest",
"reporters": [
"default",
"jest-allure"
],
"rootDir": "./",
"setupFilesAfterEnv": [
"jest-allure/dist/setup"
],
"testEnvironment": "node",
"testRegex": [
"src/specs/*.*/*.spec.ts"
],
"transformIgnorePatterns": [
"\\\\node_modules\\\\"
],
"testTimeout": 300000
},
"dependencies": {
"add": "^2.0.6",
"npx": "^10.2.2"
}
}
Run NPM install
npm i
Create folder structure
mkdir src
cd src
mkdir specs
mkdir pageObjects
mkdir actions
Creating your first test
Create a test file called {testName}.spec.ts in your specs folder
import { WebBrowser, WebBrowserProvider } from "carmation-next-framework";
import { Strategies } from "carmation-next-framework";
import { Actions } from "../actions/actions";
describe("some testSuite", () => {
let browser: WebBrowser;
beforeEach(async () => {
});
afterEach(async () => {
await browser.close();
});
it("some test", async function () {
browser = await WebBrowserProvider.Get(Strategies.desktop)
const actions = new Actions(browser);
actions.searchWithGoogle();
});
});
Create a action file called action.ts
import { WebBrowser } from "carmation-next-framework";
import { action } from "carmation-next-framework";
import { GooglePage } from "pageObjects/googlePage";
export class Actions {
browser: WebBrowser;
constructor(browser: WebBrowser) {
this.browser = browser;
}
@action('continue the flow trough the product configuration phase')
public async searchWithGoogle() {
let googlePage = new GooglePage(this.browser)
await this.browser.goTo(`https://www.google.com`);
await (await googlePage.searchField()).type('string');
await (await googlePage.searchButton()).click();
}
}
Create a action file called googlePage.ts
import { PageObject } from "carmation-next-framework";
import { WebBrowser } from "carmation-next-framework";
import { WebElement, Locator } from "carmation-next-framework";
export class GooglePage extends PageObject{
constructor(browser: WebBrowser){
super(browser);
}
public async searchField() : Promise<WebElement> {
return await super.Element(new Locator(`//*[@name='q']`))
}
public async searchButton() : Promise<WebElement> {
return await super.Element(new Locator(`//*[@name='btnK']`));
}
}
Run NPM install
npm run test
Reporting
Generate report
report:gen
Start reporting server
report:open