0.0.17 • Published 4 years ago

carmation-next-framework v0.0.17

Weekly downloads
1
License
MIT license
Repository
-
Last release
4 years ago

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?

Carmation-next-framework uses Puppeteer to interact with Chrome, which can be run headed. It follows the strategie pattern and consists of three principles:

  1. Browser(desktop, mobile, tablet)
  2. Element(WebElement, Locator, WebElementProvider)
  3. 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

0.0.17

4 years ago

0.0.16

4 years ago

0.0.15

4 years ago

0.0.14

4 years ago

0.0.13

4 years ago

0.0.12

4 years ago

0.0.10

4 years ago

0.0.11

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago