npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

protractor-tester-utils

v1.5.33

Published

Protractor Tester Utils will provide handy utils for make your test better and easy

Downloads

125

Readme

protractor-tester-utils

The Protractor Tester Utils module will help the tester who works with the protractor by providing various handy Utilities. Easy to set up and use it in any protractor framework. It also now supports API calls and it can be used in the Protractor directly.

Installation

npm install protractor-tester-utils
yarn add protractor-tester-utils

Page Object setup

Import getPageObject from protractor-tester-utils and call and assign the getPageObject method with argument (file path of the .yaml or .json) to params pageObject variable. Sample snippet provided below.

import { getPageObject } from "protractor-tester-utils";
import { Config } from "protractor";

export let config: Config = {
    framework: "jasmine",
    capabilities: {
        browserName: "chrome",
    },
    seleniumAddress: "http://localhost:4444/wd/hub",
    specs: "spec.js"],
    params: {
        pageObject: getPageObject("../../../src/example/pages"),
    },
};

Usage

Javascript

const { getElement, validateGetText } = require("protractor-tester-utils");

describe("Sample Suit", () => {
    it("Test#1", () => {
        const homeHeader = getElement("header");
        validateGetText(homeHeader, "Header Title");
    });
});
Case will be Pass if the value matched exit 0

TypeScript

import { elementGetText } from "protractor-tester-utils";
console.log(elementGetText("header"));
Output should be 'Header Title'

Available utility

| Available Utility | Parameters | Return Type | Description | | ---------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Action Utils | | | | | holdClickUnholdCtrlKey | (locator: ElementFinder) | Promise< void > | This util will help to perform hold ctrl and mouse click and unhold ctrl | | holdClickUnholdShiftKey | (locator: ElementFinder) | Promise< void > | This util will help to perform hold shift and mouse click and unhold shift | | holdCtrlKey | | Promise< void > | This util will help to perform hold ctrl key | | holdShiftKey | | Promise< void > | This util will help to perform hold shift key | | mouseClick | (locator: string / ElementFinder) | Promise< void > | This util will help to perform mouse click | | mouseClickAndHold | (locator: string / ElementFinder) | Promise< void > | This util will help to perform mouse click and hold | | mouseDoubleClick | (locator: string / ElementFinder) | Promise< void > | This util will help to perform mouse double click | | mouseDragDrop | (locator: string / ElementFinder, targetLocator: string / ElementFinder) | Promise< void > | This util will help to perform mouse drag and drop | | mouseHover | (locator: string / ElementFinder) | Promise< void > | This util will help to perform mouse hover on element | | mouseReleaseClickAndUnhold | (locator: string / ElementFinder) | Promise< void > | This util will help to perform release mouse hold | | mouseSwipeLeftRight | (locator: string / ElementFinder, distance: number, options: IConfig = {}) | Promise< void > | This util will help to perform swife left or right.example: left (distance=-50), right (distance=50) | | mouseSwipeUpDown | (locator: string / ElementFinder, distance: number, options: IConfig = {}) | Promise< void > | This util will help to perform swife Down or Up.example: Up (distance=-50), Down (distance=50) | | pressKey | (key: any, options: IConfig = {}) | Promise< void > | This util will help to perform keyboard actions using sendKeys. example: pressKey(protractor.Key.ENTER) | | pressTabKey | | Promise< void > | THis util will help to perform keyboard press tap key | | unholdCtrlKey | | Promise< void > | This util will help to perform unhold ctrl key | | unholdShiftKey | | Promise< void > | This util will help to perform unhold shift key | | Assertion Utils | | | | | assertContains | (actual: any, expected: any) | void | This util will check the contains value in given string | | assertEqual | (actual: any, expected: any) | void | This util will check the given value is equal | | assertArrJsonEqual | (actual: any, expected: any) | void | This util will check the given json / array value is equal | | assertEqualLength | (value: any, size: number) | void | This util will check the given value is in equal length | | assertInvisibilityOf | (locator: string / ElementFinder, millisecs: number = 10000) | void | This util will check the given Element is visible | | assertIsFalse | (value: any) | void | This util will check the given value is false | | assertIsTrue | (value: any) | void | This util will check the given value is true | | assertNotContains | (actual: any, expected: any) | void | This util will check the given value is not in contains | | assertNotEqual | (actual: any, expected: any) | void | This util will check the given value is not equal | | assertNotArrJsonEqual | (actual: any, expected: any) | void | This util will check the given json / array value is not equal | | assertPresenceOf | (locator: string / ElementFinder, millisecs: number = 10000) | void | This util will check the given Element is Present | | assertVisibilityOf | (locator: string / ElementFinder, millisecs: number = 10000) | void | This util will check the given Element is visible | | assertOrderedDeepEquality | (actual: any, expected: any) | void | This util will check the given json / array value is Ordered Deep Equality | | assertUnorderedDeepEquality | (actual: any, expected: any) | void | This util will check the given json / array value is Unordered Deep Equality | | assertObjKeyEqual | (actual: any, expected: any) | void | This util will check the Object key Equal | | assertObjNestedPropertyEqual | (actual: any, expectedProp: any, expectedVal?: any) | void | This util will check the Object Nested Property Equal | | assertObjPropertyEqual | (actual: any, expectedProp: any, expectedVal?: any) | void | This util will check the Object Property Equal | | assertPartialOrderedDeepEquality | (actual: any, expected: any) | void | This util will check the Partial Ordered Deep Equality | | assertPartialUnorderedDeepEquality | (actual: any, expected: any) | void | This util will check the Partial Unordered Deep Equality | | Browser Utils | | | | | browserClose | | Promise< void > | Used to close the browser instance | | browserGet | (url: string, timeoutms: number = 0) | Promise< void > | To launch URL in browser and aslo check the URL is valid before launch | | browserGetLocationAbsUrl | | Promise< any > | To Get Absolute URL for @example browser.get('http://angular.github.io/protractor/#/api'); expect(browser.getLocationAbsUrl()).toBe('http://angular.github.io/protractor/#/api'); | | browserGetPageSource | | Promise< string > | To get current page source | | browserGetTitle | | Promise< string > | To get current page title | | browserGoBack | | Promise< void > | To navigate back in browser | | browserGoForward | | Promise< void > | To navigate forward in browser | | browserQuit | | Promise< void > | To quit the browser instance | | browserRefresh | | Promise< void > | To Refresh the browser | | browserRestart | | Promise< void > | To Restart the browser instance | | browserRestartSync | | void | To Restart the browser instance in sync | | browserSetLocation | | Promise< void > | Browse to another page using in-page navigation. @example browser.get('http://angular.github.io/protractor/#/tutorial'); browser.setLocation('api'); expect(browser.getCurrentUrl()).toBe('http://angular.github.io/protractor/#/api'); | | browserSwitchTab | (tabIndex: number = 0) | Promise< void > | To Switch tabs on browser | | browserSwitchToDefaultFrame | | Promise< void > | To switch back to default frame | | browserSwitchToFrame | (indexOfFrame: number, options: IConfig = {}) | Promise< void > | To switch to frame using index | | browserWaitForAngularEnabled | (boolVal: boolean) | Promise< void > | To control angular and non angular control flow | | clicker | (locator: string / ElementFinder, timeoutms: number = 0) | Promise< void > | To perform click operation on browser by passing locator & time out in milliseconds (Optional) | | elementGetText | (locator: string / ElementFinder, options: IConfig = {}) | Promise< string > | To get the text of the element | | elementInputGetText | (locator: string / ElementFinder, options: IConfig = {}) | Promise< string > | To get the text from input field | | elementLogger | (locator: string / ElementFinder, options: IConfig = {}) | Promise< void > | To get details of the element it will print the details of the element on console | | findElementByText | (searchText: string, cssSelector: string = "div, li, option") | Promise< ElementFinder > | To find an element by text for e.g. list items | | findElementsByText | (searchText: string, cssSelector: string = "div, li, option") | (Promise< any[] / ElementFinder[] >) | To find an array of element by text for e.g. missing css selector options | | getBrowserURL | | Promise< string > | To get the current page URL | | getScreenshot | (locator: ElementFinder) | Promise< string > | Will return the element screen shot by base 64 string | | isURL | (url: string) | boolean | To validate the url | | sendkeys | (locator: string / ElementFinder, value: string / number / Promise< string / number >, timeoutms: number = 0) | Promise< void > | To set value in input fields on browsers | | stringToJSON | (jsonData: string) | any | This util will parse unformat JSON to valid JSON | | switchToFrame | (index?: number, locator?: string / ElementFinder) | Promise< void > | This util will help to switch the frame using either by index or element | | takeScreenShot | (locator: ElementFinder, filePath: string) | Promise< void > | This util will help to take screenshot and save as png file in specified file path | | Date Utils | | | | | getCurrentDay | | Promise< string > | This utill will provide specified date format | | getCustomFormatDate | (dateFormat: "dd-mm-yyyy" / "dd/mm/yyyy" / "yyyy-mm-dd" / "yyyy/mm/dd" / "m/d/yyyy" / "m-d-yyyy" / string) | Promise< string > | This utill will provide specified date format | | getDateTimeStamp | | Promise< string > | This utill will provide specified date format | | getddMMMyyyy | | Promise< string > | This utill will provide specified date format | | getddMMMyyyyhhmmss | | Promise< string > | This utill will provide specified date format | | getddMMMyyyyms | | Promise< string > | This utill will provide specified date format | | getddMMMyyyyss | | Promise< string > | This utill will provide specified date format | | getddMMyyyyhhmmss | | Promise< string > | This utill will provide specified date format | | getFutureDate | (addDays: number) | Promise< string > | This utill will provide specified date format | | getFutureDayfrmCurrentDay | (addDays: number) | Promise< string > | This utill will provide specified date format | | getPastDate | (minusDays: number) | Promise< string > | This utill will provide specified date format | | getTimeStamp | | Promise< string > | This utill will provide specified date format | | getUSFormate | | Promise< string > | This utill will provide specified date format | | Exception Utils | | | | | throwCustomError  | (err: string) | never | This util will throw custom error | | throwErrorMsg | (err: Error) | never | This util will throw error message | | throwErrorName | (err: Error) | never | This util will throw error name | | throwErrorStack | (err: Error) | never | This util will throw error stack | | Element Utils | | | | | getDynamicElement | (locatorType: "binding"/ "buttontext"/ "classname"/ "css"/ "deepcss"/ "exactbinding"/ "exactrepeater"/ "id"/ "linktext"/ "model"/ "name"/ "partialbuttontext"/ "partiallinktext"/ "repeater"/ "tagname"/ "xpath"/ string,locatorVal: string) | ElementFinder | This function will return ElementFinder based on the locator provided in argument | | getDynamicElements | (locatorType: "binding"/ "buttontext"/ "classname"/ "css"/ "deepcss"/ "exactbinding"/ "exactrepeater"/ "id"/ "linktext"/ "model"/ "name"/ "options"/ "partialbuttontext"/ "partiallinktext"/ "repeater"/ "tagname"/ "xpath"/ string,locatorVal: string) | ElementArrayFinder | This function will return ElementArrayFinder based on the locator provided in argument | | getElement | (locatorVal: string) | ElementFinder | This function will return Element Finder based on the locator provided in JSON/YAML | | getElements | (locatorVal: string) | ElementArrayFinder | This function will return Element Array Finder based on the locator provided in JSON/YAML | | JavaScript Execution Utils | | | | | jsExecAlert | (alertMsg: string) | Promise< void > | This method displays the message in alert and close after 3 seconds | | jsExecClearBrowserInstance | | Promise< void > | Util to clear cookies, session, storage | | jsExecClick | (locator: string / ElementFinder) | Promise< void > | This util will be used to click an element using JavaScriptExecutor | | jsExecHighlightElement | (locator: string / ElementFinder) | Promise< void > | This util will be used to highlight an element using JavaScriptExecutor | | jsExecMouseHoverAndClick | (locatorToHover: string / ElementFinder,locatorToClick: string / ElementFinder) | Promise< void > | This util will be used to Mouse Hover to element and Click to the specific element using JavaScriptExecutor | | jsExecOpenNewTab | (url: string) | Promise< void > | Util to open a url in a new tab | | jsExecRemoveElement | (locator: string / ElementFinder, options: IConfig) | Promise< void > | Util to remove an element from the document | | jsExecReplaceAttributeValue | (attribute: string, attributeValue: string, locator: ElementFinder) | Promise< void > | This util will be used to Replace Attibute value in DOM level | | jsExecScrollIntoView | (locator: string / ElementFinder) | Promise< void > | This util will be used to scroll to view particullar element using JavaScriptExecutor | | jsExecScrollup | | Promise< void > | This util will be used to scroll the page to Top or Up using JavaScriptExecutor | | jsExecSetDate | (locator: string / ElementFinder, date: string) | Promise< void > | This util will be used to set date using JavaScriptExecutor | | jsExecSetText | (locator: string / ElementFinder, replace: string, options: IConfig) | Promise< void > | Util to set the text to an element | | jsExecSetTextByRegEx | (locator: string / ElementFinder, search: string, replace: string, options: IConfig) | Promise< void > | Util to set the text to element by regExp | | jsExecTyper | (locator: ElementFinder, value: string) | Promise< void > | This util will be usedTo set value to Textbox using JavaScriptExecutor | | jsExecUploadFile | (filePath: string, indexOfElement: number = 0) | Promise< void > | Util to upload a file | | Request Utils | | | | | DELETE | (reqConf: IRequestOptions) | Promise< AxiosResponse< any > / undefined > | Api call for delete request | | GET | (reqConf: IRequestOptions)