Skip to content

spnraju/vscode-nightwatchjs-snippets

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

71 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NightwatchJS code snippets for Visual Studio Code

Version Installs Downloads Ratings TrendingMonthly

  • Please type "nw" first and it will list down all the commands
  • Please help with rating/feedback which might be useful in improving this further

Table of Contents

Assert-Verify

  • attributeContains(selector, attribute, expected, optionalMessage)
  • attributeEquals(selector, attribute, expected, optionalMessage)
  • containsText(selector, expectedText, optionalMessage)
  • cssClassPresent(selector, className, optionalMessage)
  • cssClassNotPresent(selector, className, optionalMessage)
  • cssProperty(selector, cssProperty, expected, optionalMessage)
  • elementPresent(selector, optionalMessage)
  • elementNotPresent(selector, optionalMessage)
  • hidden(selector, optionalMessage)
  • title(expected, optionalMessage)
  • titleContains(expected, optionalMessage)
  • urlContains(expectedText, optionalMessage)
  • urlEquals(expected, optionalMessage)
  • value(expectedText, optionalMessage)
  • valueContains(selector, expectedText, optionalMessage)
  • visible(selector, optionalMessage)

Finding Elements

  • waitForElementNotVisible(optionalUsing, selector, optionalWaitForConditionTimeout, optionalWaitForConditionPollInterval, optionalAbortOnAssertionFailure, optionalCallback, optionalMessage)
  • waitForElementNotPresent(optionalUsing, selector, optionalWaitForConditionTimeout, optionalWaitForConditionPollInterval, optionalAbortOnAssertionFailure, optionalCallback, optionalMessage)
  • waitForElementPresent(optionalUsing, selector, optionalWaitForConditionTimeout, optionalWaitForConditionPollInterval, optionalAbortOnAssertionFailure, optionalCallback, optionalMessage)
  • waitForElementVisible(optionalUsing, selector, optionalWaitForConditionTimeout, optionalWaitForConditionPollInterval, optionalAbortOnAssertionFailure, optionalCallback, optionalMessage)
  • element(using, value, callback)
  • elements(using, value, callback)
  • elementIdEquals(webElementId, otherId, callback)
  • elementIdElement(webElementId, using, value, callback)
  • elementIdElements(webElementId, using, value, callback)

Element Interaction

  • click(optionalUsing, selector, optionalCallback)
  • clearValue(selector, optionalCallback)
  • moveToElement(selector, xoffset, yoffset, optionalCallback)
  • setValue(selector, inputValue, optionalCallback)
  • submitForm(selector, optionalCallback)
  • keys(keysToSend, optionalCallback)

Element State

  • getAttribute(selector, attribute, callback)
  • getCssProperty(selector, cssProperty, callback)
  • getElementSize(selector, callback)
  • getTagName(selector, callback)
  • getText(optionalUsing, selector, callback)
  • getValue(selector, callback)
  • isVisible(selector, callback)
  • elementActive(callback)

Element Location

  • getLocation(selector, callback)
  • getLocationInView(selector, callback)

Protocol Element Commands

  • elementIdAttribute(webElementId, attributeName, callback)
  • elementIdCssProperty(webElementId, cssPropertyName, callback)
  • elementIdClear(webElementId, optionalCallback)
  • elementIdClick(webElementId, optionalCallback)
  • elementIdDisplayed(webElementId, callback)
  • elementIdEnabled(webElementId, callback)
  • elementIdLocationInView(webElementId, optionalCallback)
  • elementIdLocation(webElementId, callback)
  • elementIdName(webElementId, callback)
  • elementIdSelected(webElementId, callback)
  • elementIdSize(webElementId, callback)
  • elementIdText(webElementId, callback)
  • elementIdValue(webElementId, optionalValue, callback)
  • submit(webElementId, optionalCallback)

Document Handling

  • injectScript(scriptUrl, optionalId, optionalCallback)
  • execute(body, args, optionalCallback)
  • executeAsync(script, args, optionalCallback)
  • source(callback)

Sessions

  • end(optionalCallback)
  • getLogTypes(callback)
  • getLog(typeString, callback)
  • isLogAvailable(typeString, callback)
  • session(optionalAction, optionalSessionId, optionalCallback)
  • sessions(callback)
  • timeouts(type, ms, optionalCallback)
  • timeoutsAsyncScript(ms, optionalCallback)
  • timeoutsImplicitWait(ms, optionalCallback)
  • status(callback)
  • sessionLog(typeString, callback)
  • sessionLogTypes(callback)

Navigation

  • init(optionalURL, optionalCallback)
  • getTitle(callback)
  • urlHash(hash, optionalCallback)
  • url(optionalURL, optionalCallback)
  • back(optionalCallback)
  • forward(optionalCallback)
  • refresh(optionalCallback)
  • title(callback)

Window Related

  • closeWindow(optionalCallback)
  • resizeWindow(width, height, optionalCallback)
  • maximizeWindow(optionalCallback)
  • switchWindow(handleOrName, optionalCallback)
  • setWindowPosition(offsetX, offsetY, optionalCallback)
  • window(method, handleOrName, optionalCallback)
  • windowHandle(callback)
  • windowHandles(callback)
  • windowMaximize(optionalHandleOrName, optionalCallback)
  • windowPosition(windowHandle, offsetX, offsetY, callback)
  • windowSize(windowHandle, width, height, optionalCallback)
  • frame(optionalFrameID, optionalCallback)
  • frameParent(optionalCallback)

Cookies

  • getCookies(callback)
  • getCookie(cookieName, callback)
  • setCookie(cookieObject, optionalCallback)
  • deleteCookie(cookieName, optionalCallback)
  • deleteCookies(optionalCallback)
  • cookie(method, optionalCallbackOrCookie)

User Actions

  • doubleClick(optionalCallback)
  • mouseButtonClick(button, optionalCallback)
  • mouseButtonDown(button, optionalCallback)
  • mouseButtonUp(button, optionalCallback)
  • moveTo(optionalWebElementId, xoffset, yoffset, optionalCallback)

User Prompts

  • acceptAlert(optionalCallback)
  • dismissAlert(optionalCallback)
  • getAlertText(callback)
  • setAlertText(value, optionalCallback)

Screen Capture

  • saveScreenshot(fileName, optionalCallback)
  • screenshot(log_screenshot_data, callback)

Mobile Related

  • getOrientation(callback)
  • setOrientation(orientation, optionalCallback)
  • contexts(callback)
  • currentContext(callback)
  • setContext(context, optionalCallback)

Utilities-Debugging

  • pause(ms, optionalCallback)
  • useCss(optionalCallback)
  • useXpath(optionalCallback)
  • perform(callback)

Feedback or Issues

Please feel free to open an issue here for any issue/feedback or request for enhancement

Go to Top

Thank you for using this extension!