GithubHelp home page GithubHelp logo

isabella232 / nemo-window Goto Github PK

View Code? Open in Web Editor NEW

This project forked from krakenjs/nemo-window

0.0 0.0 0.0 25 KB

`nemo-window` is a plugin for Nemo automation framework. It provides methods to work with multiple browser-windows.

License: MIT License

JavaScript 100.00%

nemo-window's Introduction

Note: this module was forked from gkushang in order to maintain it going forward. It has been renamed nemo-window2 for the time being.

nemo-window

nemo-window is a plugin for Nemo automation framework. It provides methods to work with multiple browser-windows.

Installation

npm install nemo-window --save-dev

Configuration

Add nemo-window plugin to your config/config.json under plugins section.

    	"plugins": {
		    "window": {
		        "module": "nemo-window"
		    }
		 ...
	},
	...

Methods

	nemo.window.switchTab	: switches focus to other window
	nemo.window.switchFrame	: switches focus to new frame on page
	nemo.window.newWindow	: opens new window
	nemo.window.close		: close current window
	nemo.window.handles		: retrieve all window handles from session
	nemo.window.handle		: retrieve current window handle
	nemo.window.mainHandle	: retrieve parent window handle

switchTab(windowHandle)

Switches focus to particular Window/Tab in browser.

  • If windowHandle is not provided, switches focus alternatively.
  • If windowHandle is provided, switches focus to particular window handle.

@argument windowHandle {String} (Optional)

@returns {Web driver Promise}

Usage:
1. nemo.window.switchTab(); //switches focus alternatively

   e.g. if two windows, Window A and Window B, are open

        nemo.window.switchTab(); //switch focus to Window B
        nemo.window.switchTab(); //switch focus to Window A
        nemo.window.switchTab(); //switch focus back to Window B

2. nemo.window.switchTab('CD-W-2F3449'); //switches focus to window handle `CD-W-2F3449`

Please find the example at the end.

switchFrame(nameOrIndex)

Switches focus to another frame on page. nameOrIndex is required argument.

Please find the example at the end.

@argument nameOrIndex {String} (Required)

@returns {Web driver Promise}

Usage:
nemo.window.switchFrame('paypalTarget'); //switch focus to particular frame 'paypalTarget' on page

close()

Closes current window (and focus on an other window)

Please find the example at the end.

@returns {Web driver Promise}

Usage:
nemo.window.close(); //close the current window
Usage:
nemo.window.closeAll(); //close all the windows

newWindow(url, name)

Opens new window in browser and automatically switches focus to new window. Navigates to the Url automatically if url is provided. It is Optional. Name the new Window if name is provided. It is Optional.

Please find the example at the end.

@arguments url {String} (Optional) @arguments name {String} (Optional)

Usage:
1. nemo.window.newWindow(); //opens new window in browser, and switches focus to new Window
2. nemo.window.newWindow('www.paypal.com/signin'); //opens new window in browser and automatically navigates to `www.paypal.com/signin`
3. nemo.window.newWindow('www.paypal.com/signin', 'ppWindow'); //In addition to [2], it names the new window as `ppWindow`

handles()

Retrieve the list of all window handles available to the session.

@returns {Array of the window handles as a Promise}

Usage:
nemo.window.handles().then(callback);

mainHandle()

Retrieve main/parent window handle

Please find the example at the end.

@returns {main/parent window handle as a Promise}

Usage:
nemo.window.mainHandle().then(callback);

handle()

Retrieve current window handle

Please find the example at the end.

@returns {current window handle as a Promise}

Usage:
nemo.window.handle().then(callback);

Example

//this example assumes that window[A] is already launched by nemo

//launch new window[B] and navigate to PayPal.com. Note: it automatically switches focus to new window[B]
nemo.window.newWindow('http://www.paypal.com');

//get new window[B] handle
nemo.window.handle().then(callback);

//get main window[A] handle
nemo.window.mainHandle().then(callback); //returns main window handle

//switch to window[A], no need to provide handle if only two windows are open. it switches alternatively
nemo.window.switchTab(); //focus is on window[A]

//switch to window[B]
nemo.window.switchTab(); //focus is on window[B]

//close window[B] since the current focus is on window[B]. Note: it automatically switches focus to window[A]
nemo.window.close(); //close currently focused window

//this returns window[A] handle
nemo.window.handle().then(callback); //returns window[A] handle

nemo-window's People

Contributors

gkushang avatar grawk avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.