Best JavaScript code snippet using webdriverio-monorepo
test_cluster_settings.js
Source:test_cluster_settings.js
...61 'Settings tab is rendered correctly': function() {62 return this.remote63 .setFindTimeout(1000)64 .then(function() {65 return common.isElementEnabled('.btn-load-defaults', 'Load defaults button is enabled');66 })67 .then(function() {68 return common.isElementDisabled('.btn-revert-changes', 'Cancel Changes button is disabled');69 })70 .then(function() {71 return common.isElementDisabled('.btn-apply-changes', 'Save Settings button is disabled');72 });73 },74 'Check Save Settings button': function() {75 return this.remote76 .setFindTimeout(1000)77 .findByCssSelector('input[type=checkbox]')78 // introduce change79 .click()80 .then(function() {81 return common.isElementEnabled('.btn-apply-changes', 'Save Settings button is enabled');82 })83 // reset the change84 .click()85 .then(function() {86 return common.isElementDisabled('.btn-apply-changes', 'Save Settings button is disabled');87 })88 .end();89 },90 'Check Cancel Changes button': function() {91 return this.remote92 .setFindTimeout(1000)93 // introduce change94 .findByCssSelector('input[type=checkbox]')95 .click()96 .end()97 .then(function() {98 // try to move out of Settings tab99 return clusterPage.goToTab('Dashboard');100 })101 .then(function() {102 // check Discard Chasnges dialog appears103 return modal.waitToOpen();104 })105 .then(function() {106 return modal.close();107 })108 // reset changes109 .findByCssSelector('.btn-revert-changes')110 .click()111 .end()112 .then(function() {113 return common.isElementDisabled('.btn-apply-changes', 'Save Settings button is disabled after changes were cancelled');114 });115 },116 'Check changes saving': function() {117 return this.remote118 .setFindTimeout(1000)119 // introduce change120 .findByCssSelector('input[type=checkbox]')121 .click()122 .end()123 .then(function() {124 return common.isElementEnabled('.btn-apply-changes', 'Save Settings button is enabled');125 })126 // save changes127 .findByCssSelector('.btn-apply-changes')128 .click()129 .end()130 .then(function() {131 return settingsPage.waitForRequestCompleted();132 })133 .then(function() {134 return common.isElementDisabled('.btn-revert-changes', 'Cancel Changes button is disabled after changes were saved successfully');135 });136 },137 'Check loading of defaults': function() {138 return this.remote139 .setFindTimeout(1000)140 // load defaults141 .findByCssSelector('.btn-load-defaults')142 .click()143 .end()144 .then(function() {145 return settingsPage.waitForRequestCompleted();146 })147 .then(function() {148 return common.isElementEnabled('.btn-apply-changes', 'Save Settings button is enabled after defaults were loaded');149 })150 .then(function() {151 return common.isElementEnabled('.btn-revert-changes', 'Cancel Changes button is enabled after defaults were loaded');152 })153 // revert the change154 .findByCssSelector('.btn-revert-changes')155 .click()156 .end();157 },158 'The choice of subgroup is preserved when user navigates through the cluster tabs': function() {159 return this.remote160 .setFindTimeout(1000)161 .then(function() {162 return common.clickLink('Syslog');163 })164 .then(function() {165 return clusterPage.goToTab('Dashboard');...
ReactCornerstoneViewportHooks.js
Source:ReactCornerstoneViewportHooks.js
1/* eslint-disable no-unused-vars */2import cornerstone from "cornerstone-core";3import cornerstoneTools from "cornerstone-tools";4import React, { useRef, useState, useEffect, useLayoutEffect } from "react";5import PropTypes from "prop-types";6// import debounce from "lodash.debounce";7import ImageScrollbar from "./ImageScrollbar";8import ViewportOverlay from "./ViewportOverlay";9import "./ReactCornerstoneViewportHooks.css";10import {11 addInitialTools,12 cleanupStackPrefetch,13 setActiveTool,14 loadImage,15} from "./ReactCornerstoneViewportHooksHelpers";16const scrollToIndex = cornerstoneTools.importInternal("util/scrollToIndex");17/**18 * `initialDisplayImage` tracks whether this is the first time19 * `cornerstone.displayImage` is called. We need this because we have a20 * scrolling component which is used to actually scroll the images and this21 * requires setting the correct image index. Moreover, if we are provided a22 * `StackScrollMouseWheelTool` which __automagically__ updates the image23 * displayed, the only interaction is via a `cornerstone.EVENTS.NEW_IMAGE`24 * event. Thus, to keep the scrollbar and the mousewheel scrolling aligned,25 * the initial display of the image is kept separate from data manipulation.26 */27function ReactCornerstoneViewportHooks({28 imageIds = [],29 imageIndex = 0,30 tools = [],31 activeToolName = "Wwwc",32 isStackPrefetchEnabled = false,33 eventListeners = [],34 handleNewImage = () => {},35 setIsImageLoading = () => {},36 onElementEnabled = () => {},37 handleImageProgress = (e) => {},38 errorHandler,39 containerCssClass = "annotation-container",40 elementCssClass = "annotation-element",41 style = {},42 isOverlayVisible = true,43}) {44 const cornerstoneViewportEl = useRef(null);45 const [isElementEnabled, setIsElementEnabled] = useState(false);46 const [initialDisplayImage, setInitialDisplayImage] = useState(true);47 const [imageIdIndex, setImageIdIndex] = useState(imageIndex);48 const [viewportInfo, setViewportInfo] = useState({49 scale: 1,50 windowCenter: 0,51 windowWidth: 1,52 rotationDegrees: 0,53 isFlippedVertically: false,54 isFlippedHorizontally: false,55 });56 const scrollbarMax = imageIds.length ? imageIds.length - 1 : 0;57 // TODO: the height should ideally be a prop58 const scrollbarHeight = cornerstoneViewportEl.current59 ? `${cornerstoneViewportEl.current.clientHeight - 20}px`60 : "630px";61 /*62 useEffect(() => {63 // Unique list of event names64 const cornerstoneEvents = Object.values(cornerstone.EVENTS);65 const cornerstoneToolsEvents = Object.values(cornerstoneTools.EVENTS);66 const csEventNames = cornerstoneEvents.concat(cornerstoneToolsEvents);67 console.log(csEventNames);68 }, []);69 */70 //71 // window resize72 //73 useLayoutEffect(() => {74 function handleWindowResize() {75 // console.log(window.innerWidth, window.innerHeight);76 const element = cornerstoneViewportEl.current;77 cornerstone.resize(element);78 }79 window.addEventListener("resize", handleWindowResize);80 return () => window.removeEventListener("resize", handleWindowResize);81 }, []);82 //83 // initialize element84 //85 useEffect(() => {86 const element = cornerstoneViewportEl.current;87 cornerstone.enable(element);88 cornerstoneTools.addStackStateManager(element, ["stack"]);89 setIsElementEnabled(true);90 return () => {91 cornerstone.disable(element);92 };93 }, []);94 //95 // stack96 //97 useEffect(() => {98 const element = cornerstoneViewportEl.current;99 cornerstoneTools.clearToolState(element, "stack");100 cornerstoneTools.addToolState(element, "stack", {101 imageIds: [...imageIds],102 currentImageIdIndex: imageIndex,103 });104 }, [imageIds, imageIndex]);105 //106 // tools107 //108 useEffect(() => {109 const element = cornerstoneViewportEl.current;110 if (isElementEnabled) {111 addInitialTools(element, tools, isStackPrefetchEnabled);112 }113 return () => {114 if (isElementEnabled) {115 cleanupStackPrefetch(element, isStackPrefetchEnabled);116 }117 };118 }, [isElementEnabled, isStackPrefetchEnabled, tools]);119 //120 // activeTool121 //122 useEffect(() => {123 if (isElementEnabled) {124 const element = cornerstoneViewportEl.current;125 setActiveTool(element, activeToolName);126 }127 }, [isElementEnabled, activeToolName]);128 //129 // initial image load130 //131 useEffect(() => {132 const element = cornerstoneViewportEl.current;133 if (isElementEnabled && imageIds.length && initialDisplayImage) {134 loadImage({135 element,136 imageIds,137 imageIdIndex,138 setIsImageLoading,139 setInitialDisplayImage,140 errorHandler,141 });142 }143 }, [144 isElementEnabled,145 imageIds,146 imageIdIndex,147 initialDisplayImage,148 setInitialDisplayImage,149 setIsImageLoading,150 errorHandler,151 ]);152 //153 // cornerstone events154 //155 useEffect(() => {156 const element = cornerstoneViewportEl.current;157 const onNewImage = (event) => {158 const { imageId } = event.detail.image;159 const currentImageIdIndex = imageIds.indexOf(imageId);160 setImageIdIndex(currentImageIdIndex);161 handleNewImage(element, imageId);162 };163 const onImageRendered = (event) => {164 const viewport = event.detail.viewport;165 setViewportInfo({166 scale: viewport.scale,167 windowCenter: viewport.voi.windowCenter,168 windowWidth: viewport.voi.windowWidth,169 rotationDegrees: viewport.rotation,170 isFlippedVertically: viewport.vflip,171 isFlippedHorizontally: viewport.hflip,172 });173 };174 const onImageProgress = (event) => {175 handleImageProgress(event);176 };177 if (isElementEnabled) {178 element["addEventListener"](cornerstone.EVENTS.NEW_IMAGE, onNewImage);179 element["addEventListener"](180 cornerstone.EVENTS.IMAGE_RENDERED,181 onImageRendered,182 );183 cornerstone.events["addEventListener"](184 "cornerstoneimageloadprogress",185 onImageProgress,186 );187 }188 return () => {189 element["removeEventListener"](cornerstone.EVENTS.NEW_IMAGE, onNewImage);190 element["removeEventListener"](191 cornerstone.EVENTS.IMAGE_RENDERED,192 onImageRendered,193 );194 cornerstone.events["removeEventListener"](195 "cornerstoneimageloadprogress",196 onImageProgress,197 );198 };199 }, [200 isElementEnabled,201 imageIds,202 setImageIdIndex,203 setViewportInfo,204 handleNewImage,205 handleImageProgress,206 ]);207 //208 // external event listeners209 //210 useEffect(() => {211 const element = cornerstoneViewportEl.current;212 if (isElementEnabled) {213 for (const eventListener of eventListeners) {214 element.addEventListener(215 eventListener.eventName,216 eventListener.handler,217 );218 }219 }220 return () => {221 if (isElementEnabled) {222 for (const eventListener of eventListeners) {223 element.removeEventListener(224 eventListener.eventName,225 eventListener.handler,226 );227 }228 }229 };230 }, [isElementEnabled, eventListeners]);231 useEffect(() => {232 const element = cornerstoneViewportEl.current;233 if (isElementEnabled) {234 onElementEnabled(element);235 }236 }, [isElementEnabled, onElementEnabled]);237 //238 // handlers239 //240 const imageSliderOnInputCallback = (value) => {241 const element = cornerstoneViewportEl.current;242 setImageIdIndex(value);243 scrollToIndex(element, value);244 };245 const preventMouseInteraction = function (e) {246 e.preventDefault();247 };248 return (249 <React.Fragment>250 <div style={style} className={containerCssClass}>251 <div252 className={elementCssClass}253 ref={cornerstoneViewportEl}254 onContextMenu={preventMouseInteraction}255 onMouseDown={preventMouseInteraction}256 >257 {/* This classname is important in that it tells `cornerstone` to not258 * create a new canvas element when we "enable" the `viewport-element`259 */}260 <canvas className="cornerstone-canvas" />261 {isOverlayVisible && (262 <ViewportOverlay263 imageIndex={imageIdIndex + 1}264 stackSize={imageIds.length}265 scale={viewportInfo.scale}266 windowWidth={viewportInfo.windowWidth}267 windowCenter={viewportInfo.windowCenter}268 imageId={imageIds.length ? imageIds[imageIdIndex] : ""}269 />270 )}271 </div>272 <ImageScrollbar273 onInputCallback={imageSliderOnInputCallback}274 max={scrollbarMax}275 height={scrollbarHeight}276 value={imageIdIndex}277 />278 </div>279 </React.Fragment>280 );281}282ReactCornerstoneViewportHooks.propTypes = {283 imageIds: PropTypes.arrayOf(PropTypes.string).isRequired, // list of strings with `wadouri:` prefix284 imageIndex: PropTypes.number,285 // Controlled286 activeToolName: PropTypes.string,287 tools: PropTypes.arrayOf(288 PropTypes.oneOfType([289 // String290 PropTypes.string,291 // Object292 PropTypes.shape({293 name: PropTypes.string, // Tool Name294 toolClass: PropTypes.func, // Custom (ToolClass)295 props: PropTypes.Object, // Props to Pass to `addTool`296 mode: PropTypes.string, // Initial mode, if one other than default297 modeOptions: PropTypes.Object, // { mouseButtonMask: [int] }298 }),299 ]),300 ),301 // Optional302 // isActive ?? classname -> active303 children: PropTypes.node,304 cornerstoneOptions: PropTypes.object, // cornerstone.enable options305 isStackPrefetchEnabled: PropTypes.bool, // should prefetch?306 // CINE307 isPlaying: PropTypes.bool,308 frameRate: PropTypes.number, // Between 1 and ?309 //310 setViewportActive: PropTypes.func, // Called when viewport should be set to active?311 onNewImage: PropTypes.func,312 handleImageProgress: PropTypes.func,313 onNewImageDebounceTime: PropTypes.number,314 viewportOverlayComponent: PropTypes.oneOfType([315 PropTypes.string,316 PropTypes.func,317 ]),318 // Cornerstone Events319 onElementEnabled: PropTypes.func, // Escape hatch320 eventListeners: PropTypes.arrayOf(321 PropTypes.shape({322 // target: PropTypes.oneOf(["element", "cornerstone"]).isRequired,323 eventName: PropTypes.string.isRequired,324 handler: PropTypes.func.isRequired,325 }),326 ),327 startLoadHandler: PropTypes.func,328 endLoadHandler: PropTypes.func,329 loadIndicatorDelay: PropTypes.number,330 loadingIndicatorComponent: PropTypes.oneOfType([331 PropTypes.element,332 PropTypes.func,333 ]),334 resizeThrottleMs: PropTypes.number, // 0 to disable335 //336 style: PropTypes.object,337 // className: PropTypes.string,338 containerCssClass: PropTypes.string,339 elementCssClass: PropTypes.string,340 isOverlayVisible: PropTypes.bool,341};...
interaction.js
Source:interaction.js
...93 }94 let a11y = accessibility.get(strict);95 return a11y.getAccessible(el, true).then(acc => {96 a11y.checkVisible(acc, el, visible);97 if (atom.isElementEnabled(el)) {98 a11y.checkEnabled(acc, el, true);99 a11y.checkActionable(acc, el);100 if (element.isXULElement(el)) {101 el.click();102 } else {103 let rects = el.getClientRects();104 event.synthesizeMouseAtPoint(105 rects[0].left + rects[0].width / 2,106 rects[0].top + rects[0].height / 2,107 {} /* opts */,108 win);109 }110 } else {111 throw new InvalidElementStateError("Element is not enabled");112 }113 });114};115/**116 * Send keys to element.117 *118 * @param {DOMElement|XULElement} el119 * Element to send key events to.120 * @param {Array.<string>} value121 * Sequence of keystrokes to send to the element.122 * @param {boolean} ignoreVisibility123 * Flag to enable or disable element visibility tests.124 * @param {boolean=} strict125 * Enforce strict accessibility tests.126 */127interaction.sendKeysToElement = function(el, value, ignoreVisibility, strict = false) {128 let win = getWindow(el);129 let a11y = accessibility.get(strict);130 return a11y.getAccessible(el, true).then(acc => {131 a11y.checkActionable(acc, el);132 event.sendKeysToElement(value, el, {ignoreVisibility: false}, win);133 });134};135/**136 * Determine the element displayedness of an element.137 *138 * @param {DOMElement|XULElement} el139 * Element to determine displayedness of.140 * @param {boolean=} strict141 * Enforce strict accessibility tests.142 *143 * @return {boolean}144 * True if element is displayed, false otherwise.145 */146interaction.isElementDisplayed = function(el, strict = false) {147 let win = getWindow(el);148 let displayed = atom.isElementDisplayed(el, win);149 let a11y = accessibility.get(strict);150 return a11y.getAccessible(el).then(acc => {151 a11y.checkVisible(acc, el, displayed);152 return displayed;153 });154};155/**156 * Check if element is enabled.157 *158 * @param {DOMElement|XULElement} el159 * Element to test if is enabled.160 *161 * @return {boolean}162 * True if enabled, false otherwise.163 */164interaction.isElementEnabled = function(el, strict = false) {165 let enabled = true;166 let win = getWindow(el);167 if (element.isXULElement(el)) {168 // check if XUL element supports disabled attribute169 if (DISABLED_ATTRIBUTE_SUPPORTED_XUL.has(el.tagName.toUpperCase())) {170 let disabled = atom.getElementAttribute(el, "disabled", win);171 if (disabled && disabled === "true") {172 enabled = false;173 }174 }175 } else {176 enabled = atom.isElementEnabled(el, {frame: win});177 }178 let a11y = accessibility.get(strict);179 return a11y.getAccessible(el).then(acc => {180 a11y.checkEnabled(acc, el, enabled);181 return enabled;182 });183};184/**185 * Determines if the referenced element is selected or not.186 *187 * This operation only makes sense on input elements of the Checkbox-188 * and Radio Button states, or option elements.189 *190 * @param {DOMElement|XULElement} el...
magnifying-glass-viewport-tool.directive.js
Source:magnifying-glass-viewport-tool.directive.js
1(function() {2 'use strict';3 angular4 .module('webviewer')5 .directive('wvMagnifyingGlassViewportTool', wvMagnifyingGlassViewportTool)6 .config(function($provide) {7 $provide.decorator('wvViewportDirective', function($delegate) {8 var directive = $delegate[0];9 directive.require['wvMagnifyingGlassViewportTool'] = '?^wvMagnifyingGlassViewportTool';10 return $delegate;11 });12 });13 /* @ngInject */14 function wvMagnifyingGlassViewportTool($parse, WvBaseTool) {15 var directive = {16 require: 'wvMagnifyingGlassViewportTool',17 controller: MagnifyingGlassCtrl,18 link: link,19 restrict: 'A',20 scope: false21 };22 function link(scope, element, attrs, tool) {23 var wvMagnifyingGlassViewportToolParser = $parse(attrs.wvMagnifyingGlassViewportTool);24 25 // bind attributes -> tool26 scope.$watch(wvMagnifyingGlassViewportToolParser, function(newConfig, oldConfig) {27 // Set magnifying glass configuration.28 var csConfig = {29 // Canvas' width/height in pixel.30 magnifySize: newConfig.magnifyingGlassSize,31 // Zoom depth.32 magnificationLevel: newConfig.magnificationLevel33 };34 cornerstoneTools.magnify.setConfiguration(csConfig);35 // The `cornerstoneTools.magnify.setConfiguration` method36 // doesn't update the configuration. We have to manualy disable37 // the magnify tool to reset it.38 if (oldConfig.enabled || !newConfig.enabled && oldConfig !== newConfig) {39 tool.deactivate();40 }41 // Activate back the magnifying.42 if (newConfig.enabled) {43 tool.activate();44 // Ensure the magnifying glass always stay on top of45 // everything.46 var magnifyingGlassCanvasJqEl = $('.magnifyTool');47 var magnifyingGlassCanvasEl = magnifyingGlassCanvasJqEl[0];48 magnifyingGlassCanvasJqEl.css('z-index', 1000000);49 // The `cornerstoneTools.magnify.setConfiguration` method50 // doesn't update the glass size. We have to manually change51 // the magnifying glass size.52 if (oldConfig.magnifyingGlassSize !== newConfig.magnifyingGlassSize) {53 magnifyingGlassCanvasEl.width = csConfig.magnifySize;54 magnifyingGlassCanvasEl.height = csConfig.magnifySize;55 }56 }57 }, true);58 }59 /* @ngInject */60 function MagnifyingGlassCtrl(wvPanViewportTool, wvZoomViewportTool, $scope) {61 WvBaseTool.call(this, 'magnify', 'magnifyTouchDrag', false, wvPanViewportTool, wvZoomViewportTool, $scope);62 // BaseTool class as been made for annotation. This is not one.63 // We overide this method so the glass is not shown once toggled64 // off. When we deactivate an annotation, we let the annotation65 // shown, but only deactivate the inputs.66 // For tools related to cornerstone (@todo split BaseTool in AnnotationTools & others)67 this._deactivateInputs = function(viewport) {68 // Unlisten to events69 var enabledElement = viewport.getEnabledElement();70 cornerstoneTools.mouseInput.disable(enabledElement);71 cornerstoneTools.touchInput.disable(enabledElement);72 // Set tool in disable mode.73 cornerstoneTools[this.toolName].disable(enabledElement, 1);74 if (this.toolName2) {75 cornerstoneTools[this.toolName2].disable(enabledElement);76 }77 };78 this.register = function(viewport) {79 this.viewports.push(viewport)80 if (this.isActivated) {81 this.activate(viewport);82 }83 };84 this.unregister = function(viewport) {85 if (cornerstoneTools[this.toolName]) {86 // Set tool in disable mode (it's a 1D state machine with 487 // states) - don't display annotations & ignore inputs.88 // 1. Retrieve DOM element89 var enabledElement = viewport.getEnabledElement();90 // 2. Ignore exception if no image is shown in the viewport91 var isElementEnabled = undefined;92 try {93 isElementEnabled = true;94 cornerstone.getEnabledElement(enabledElement); 95 }96 catch (exc) {97 isElementEnabled = false;98 }99 // 3. Change tool state100 // if (isElementEnabled) {101 // cornerstoneTools[this.toolName].enable(enabledElement, 1);102 // if (this.toolName2) {103 // cornerstoneTools[this.toolName2].activate(enabledElement);104 // }105 // }106 }107 this._unlistenModelChange(viewport);108 109 _.pull(this.viewports, viewport);110 };111 }112 MagnifyingGlassCtrl.prototype = Object.create(WvBaseTool.prototype)113 MagnifyingGlassCtrl.prototype.constructor = MagnifyingGlassCtrl;114 115 return directive;116 }...
visit.js
Source:visit.js
1const {appAndroidConfig} = require('./configs')2const webdriverio = require('webdriverio');3let client;4let startApp = async () => {5 client = await webdriverio.remote(appAndroidConfig);6}7let closeApp = () => {8 client.deleteSession();9}10let getElementByResourceId = (id) => {11 return client.$(`android=new UiSelector().resourceId("com.ideomobile.maccabi:id/${id}")`)12}13let getElementByText = (text) => {14 return client.$(`android=new UiSelector().textContains("${text}")`)15}16let isElementDisplayed = async (element) => {17 element.waitForDisplayed(20000)18 return await element.isDisplayed()19}20let isElementEnabled = async (element_id) => {21 const element = await getElementByResourceId(element_id)22 return await element.isEnabled()23}24 25let clickElement = async (element_id) => {26 const element = await getElementByResourceId(element_id)27 await element.click()28}29let clickElementByAccessibilityId = async (accessibility_id) => {30 const element = await client.$("~"+accessibility_id)31 await element.click()32}33let scrollToElement = async (text) => {34 const elementSelector = `new UiScrollable(new UiSelector()).scrollIntoView(text(\"${text}"))`35 return await client.$(`android=${elementSelector}`) 36}37let closeWhatsNewAd = async () => {38 const whatsNew = await getElementByText("×× ××ש ××פ××קצ××?")39 let whatsNewisDisplayed = await isElementDisplayed(whatsNew)40 if ( whatsNewisDisplayed ) {41 await clickElement('ib_whats_new_close')42 }43}44let openNoCardVisitForm = async () => {45 await client.setTimeout({ 'implicit': 15000 })46 await closeWhatsNewAd()47 48 await clickElement('btn_toggleDrawer')49 50 let openCard = await scrollToElement('××ק×ר ××× ×ר××ס')51 await openCard.click()52 53}54let setValueToElement = async (element_id, value) => {55 const textField = await getElementByResourceId(element_id)56 await textField.setValue( value ); 57}58let getElementText = async (element_id) => {59 const textElement = await getElementByResourceId(element_id)60 return await textElement.getText();61}62let setFormValues = async (id_number, password) => {63 await setValueToElement( 'textInputEditText', id_number )64 await setValueToElement( 'textInputEditTextPassword', password )65}66let accountLogin = async (id_number, password) => {67 await setFormValues(id_number, password)68 await clickElement('enterButton')69}70let chooseResonScreen = async () => {71 const chooseReson = await getElementByText("×× ×ס××× ××××× ×ª ××ק×ר ××× ×ר××ס?")72 return await isElementDisplayed(chooseReson)73}74module.exports = {75 client,76 startApp,77 closeApp,78 getElementByResourceId,79 getElementByText,80 isElementDisplayed,81 isElementEnabled,82 clickElement,83 clickElementByAccessibilityId,84 scrollToElement,85 closeWhatsNewAd,86 openNoCardVisitForm,87 setValueToElement,88 getElementText,89 setFormValues,90 accountLogin,91 chooseResonScreen...
basePage.js
Source:basePage.js
1const { By, Key, until } = require('selenium-webdriver');2 function BasePage(webdriver) {3 this.driver = webdriver;4 let driver = this.driver;5 let actions = driver.actions({ bridge: true });6 // Visit Website7 this.visit = async function (Url) {8 return await driver.get(Url);9 };10 // Maximize window11 this.openApp = async function () {12 await driver.manage().window().maximize();13 await driver.manage().deleteAllCookies();14 };15 // Quit current session16 this.quit = async function () {17 return await driver.quit();18 };19 // wait and find a specific element with it's id20 this.findById = async function (id) {21 await driver.wait(until.elementLocated(By.id(id)), 10000, 'wait for ID element');22 return await driver.findElement(By.id(id));23 };24 // wait and find a specific element with it's CSS Selector25 this.findByCss = async function (css) {26 await driver.wait(until.elementLocated(By.css(css)), 20000, 'wait for Css element');27 return await driver.findElement(By.css(css));28 };29 // wait and find a specific element with it's Classname30 this.findByclassName = async function (className) {31 await driver.wait(until.elementLocated(By.className(className)), 10000, 'wait for className element');32 return await driver.findElement(By.className(className));33 };34 // wait and find a specific element with it's XPath35 this.findByXpath = async function (xpath) {36 await driver.wait(until.elementLocated(By.xpath(xpath)), 10000, 'wait for Xpath element');37 return await driver.findElement(By.xpath(xpath));38 };39 // wait and find an array of elements with it's XPath40 this.findAll = async function (xpath) {41 await driver.wait(until.elementsLocated(By.xpath(xpath)), 10000, 'wait for Xpath element');42 return await driver.findElements(By.xpath(xpath));43 };44 this.click = async function (element) {45 return await driver.executeScript("return arguments[0].click();", element);46 };47 this.write = async function (element, txt) {48 return await element.sendKeys(txt);49 };50 this.elementIsVisible = async function (locator) {51 var isElementVisible = await locator.getCssValue("height");52 while (!(isElementVisible)) {53 return await driver54 .wait(until.elementIsVisible(locator), 30000);55 }56 return isElementVisible;57 };58 this.elementIsEnabled = async function (locator) {59 var isElementEnabled = await locator.getCssValue("height");60 while (!(isElementEnabled)) {61 return await driver62 .wait(until.elementIsEnabled(locator), 30000);63 }64 return isElementEnabled;65 };66};...
trickleView.js
Source:trickleView.js
...19 this.on("stepunlock", this.onStepUnlock);20 },21 onPreRender: function(view) {22 this.completionAttribute = Adapt.trickle.getCompletionAttribute();23 if (!this.isElementEnabled()) return;24 Adapt.trigger("trickle:preRender", this);25 },26 onPostRender: function(view) {27 if (view.model.get("_id") !== this.model.get("_id")) return;28 if (!this.isElementEnabled()) return;29 Adapt.trigger("trickle:postRender", this);30 },31 isElementEnabled: function() {32 var trickle = Adapt.trickle.getModelConfig(this.model);33 if (!trickle) return false;34 if (this.model.get(this.completionAttribute)) return false;35 var isArticleWithOnChildren = (this.model.get("_type") === "article" && trickle._onChildren);36 if (isArticleWithOnChildren) {37 return false;38 }39 if (trickle._isEnabled === true) return true;40 return false;41 },42 onStepLock: function() {43 if (!this.isElementEnabled()) {44 this.continueToNext();45 return;46 }47 var trickle = Adapt.trickle.getModelConfig(this.model);48 var isSteplocking = (trickle._stepLocking && trickle._stepLocking._isEnabled);49 if (!isSteplocking) {50 this.continueToNext();51 return;52 }53 Adapt.trigger("trickle:steplock", this);54 this.isSteplocked = true;55 },56 continueToNext: function() {57 Adapt.trigger("trickle:continue", this);...
isElementEnabled.js
Source:isElementEnabled.js
...4});5exports.default = isElementEnabled;6var _getElementAttribute = _interopRequireDefault(require("./getElementAttribute"));7function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }8async function isElementEnabled({9 elementId10}) {11 const result = await _getElementAttribute.default.call(this, {12 elementId,13 name: 'disabled'14 });15 return result === null;...
Using AI Code Generation
1var webdriverio = require('webdriverio');2var options = {3 desiredCapabilities: {4 }5};6 .remote(options)7 .init()8 .isElementEnabled('input[name="q"]')9 .then(function(isEnabled) {10 console.log(isEnabled);11 })12 .end();13isElementSelected(selector)14var webdriverio = require('webdriverio');15var options = {16 desiredCapabilities: {17 }18};19 .remote(options)20 .init()21 .isElementSelected('input[name="q"]')22 .then(function(isSelected) {23 console.log(isSelected);24 })25 .end();26isElementDisplayed(selector)27var webdriverio = require('webdriverio');28var options = {29 desiredCapabilities: {30 }31};32 .remote(options)33 .init()34 .isElementDisplayed('input[name="q"]')35 .then(function(isDisplayed) {36 console.log(isDisplayed);37 })38 .end();39isElementExisting(selector)
Using AI Code Generation
1var webdriverio = require('webdriverio');2var options = {3 desiredCapabilities: {4 }5};6 .remote(options)7 .init()8 .getTitle().then(function(title) {9 console.log('Title was: ' + title);10 })11 .end();12 .remote(options)13 .init()14 .isElementEnabled('input[name="btnK"]').then(function(title) {15 console.log('Button is enabled: ' + title);16 })17 .end();18 .remote(options)19 .init()20 .isElementEnabled('input[name="btnK1"]').then(function(title) {21 console.log('Button is enabled: ' + title);22 })23 .end();24 .remote(options)25 .init()26 .isElementEnabled('input[name="btnK1"]').then(function(title) {27 console.log('Button is enabled: ' + title);28 })29 .end();30 .remote(options)31 .init()32 .isElementEnabled('input[name="btnK1"]').then(function(title) {33 console.log('Button is enabled: ' + title);34 })35 .end();36 .remote(options)37 .init()38 .isElementEnabled('input[name="btnK1"]').then(function(title) {39 console.log('Button is enabled: ' + title);40 })41 .end();42 .remote(options)43 .init()44 .isElementEnabled('input[name="btnK1"]').then(function(title) {45 console.log('Button is enabled: ' + title);46 })47 .end();48 .remote(options)49 .init()50 .isElementEnabled('input[name="btnK1"]').then(function(title) {51 console.log('Button is enabled: ' + title);52 })53 .end();54 .remote(options)55 .init()
Using AI Code Generation
1const assert = require('assert');2const { remote } = require('webdriverio');3(async () => {4 const browser = await remote({5 capabilities: {6 }7 })8 const searchInput = await browser.$('#search_input_react');9 const isEnabled = await searchInput.isElementEnabled();10 await browser.deleteSession();11})();
Using AI Code Generation
1var webdriverio = require('webdriverio');2var options = { desiredCapabilities: { browserName: 'chrome' } };3var client = webdriverio.remote(options);4 .init()5 .setValue('#lst-ib', 'WebdriverIO')6 .click('button[name="btnG"]')7 .getTitle().then(function(title) {8 console.log('Title was: ' + title);9 })10 .element('#resultStats').then(function(element) {11 console.log(element);12 })13 .end();
Using AI Code Generation
1var webdriverio = require('webdriverio');2var options = {3 desiredCapabilities: {4 }5};6var client = webdriverio.remote(options);7 .init()8 .isElementEnabled('#lst-ib')9 .then(function(isEnabled) {10 })11 .end();
Using AI Code Generation
1describe('webdriver.io page', () => {2 it('should have the right title', () => {3 const title = browser.getTitle();4 const isEnabled = browser.isElementEnabled('input[type="search"]');5 console.log(isEnabled);6 expect(title).toEqual('WebdriverIO · Next-gen browser and mobile automation test framework for Node.js');7 });8});9exports.config = {10 capabilities: [{11 }],12 mochaOpts: {13 }14}
Using AI Code Generation
1describe('Test to check if element is enabled', () => {2 it('should check if element is enabled', () => {3 const searchInput = $('input[name="q"]');4 const isEnabled = searchInput.isEnabled();5 console.log(isEnabled);6 });7});
Using AI Code Generation
1const webdriverio = require('webdriverio');2const options = {3 desiredCapabilities: {4 }5};6const client = webdriverio.remote(options);7 .init()8 .setValue('#lst-ib', 'webdriverio')9 .click('#tsbb')10 .pause(2000)11 .isElementEnabled('#tsbb')12 .then(function(elementEnabled) {13 console.log(elementEnabled);14 })15 .end();16const webdriverio = require('webdriverio');17const assert = require('assert');18const options = {19 desiredCapabilities: {20 }21};22const client = webdriverio.remote(options);23describe('webdriverio', function() {24 it('should check if an element is enabled', function() {25 .init()26 .setValue('#lst-ib', 'webdriverio')27 .click('#tsbb')28 .pause(2000)29 .isElementEnabled('#tsbb')30 .then(function(elementEnabled) {31 assert.equal(elementEnabled, true);32 })33 .end();34 });35});36const webdriverio = require('webdriverio');37const chai = require('chai');38const options = {39 desiredCapabilities: {40 }41};42const client = webdriverio.remote(options);43describe('webdriverio', function() {44 it('should check if an element is enabled', function() {45 .init()46 .setValue('#lst-ib', 'webdriverio')47 .click('#tsbb')48 .pause(2000)49 .isElementEnabled('#tsbb')50 .then(function(elementEnabled) {51 chai.assert.equal(elementEnabled, true);52 })53 .end();54 });55});
Using AI Code Generation
1client.isElementEnabled('id', 'elementID').then(function(isEnabled) {2 console.log(isEnabled);3});4client.isElementEnabled('id', 'elementID').then(function(isEnabled) {5 console.log(isEnabled);6});7client.isElementEnabled('id', 'elementID').then(function(isEnabled) {8 console.log(isEnabled);9});
Wondering what could be a next-gen browser and mobile test automation framework that is also simple and concise? Yes, that’s right, it's WebdriverIO. Since the setup is very easy to follow compared to Selenium testing configuration, you can configure the features manually thereby being the center of attraction for automation testing. Therefore the testers adopt WedriverIO to fulfill their needs of browser testing.
Learn to run automation testing with WebdriverIO tutorial. Go from a beginner to a professional automation test expert with LambdaTest WebdriverIO tutorial.
Running Your First Automation Script - Learn the steps involved to execute your first Test Automation Script using WebdriverIO since the setup is very easy to follow and the features can be configured manually.
Selenium Automation With WebdriverIO - Read more about automation testing with WebdriverIO and how it supports both browsers and mobile devices.
Browser Commands For Selenium Testing - Understand more about the barriers faced while working on your Selenium Automation Scripts in WebdriverIO, the ‘browser’ object and how to use them?
Handling Alerts & Overlay In Selenium - Learn different types of alerts faced during automation, how to handle these alerts and pops and also overlay modal in WebdriverIO.
How To Use Selenium Locators? - Understand how Webdriver uses selenium locators in a most unique way since having to choose web elements very carefully for script execution is very important to get stable test results.
Deep Selectors In Selenium WebdriverIO - The most popular automation testing framework that is extensively adopted by all the testers at a global level is WebdriverIO. Learn how you can use Deep Selectors in Selenium WebdriverIO.
Handling Dropdown In Selenium - Learn more about handling dropdowns and how it's important while performing automated browser testing.
Automated Monkey Testing with Selenium & WebdriverIO - Understand how you can leverage the amazing quality of WebdriverIO along with selenium framework to automate monkey testing of your website or web applications.
JavaScript Testing with Selenium and WebdriverIO - Speed up your Javascript testing with Selenium and WebdriverIO.
Cross Browser Testing With WebdriverIO - Learn more with this step-by-step tutorial about WebdriverIO framework and how cross-browser testing is done with WebdriverIO.
Get 100 minutes of automation test minutes FREE!!