How to use elementClear method in Webdriverio

Best JavaScript code snippet using webdriverio-monorepo

webfind.js

Source:webfind.js Github

copy

Full Screen

1/* global rendy */2/* global io */3(function(window) {4 'use strict';5 6 window.webfind = new FindProto();7 8 function FindProto() {9 var elementSearch,10 elementClear,11 elementName,12 elementDir,13 elementResult,14 elementLoad,15 16 TMPL_MAIN,17 TMPL_FILE,18 CHANNEL = 'find-data',19 socket;20 21 function Find(element, prefix, callback) {22 var el,23 type = typeof element,24 isString = type === 'string';25 26 if (!callback) {27 callback = prefix;28 prefix = '/webfind';29 }30 31 if (isString)32 el = document.querySelector(element);33 else34 el = element;35 36 load(prefix, function(error, templates) {37 parseTemplates(templates);38 createElements(el);39 addListeners(prefix);40 41 if (typeof callback === 'function')42 callback();43 });44 45 return Find;46 }47 48 Find.setDir = function(dir) {49 if (elementDir)50 elementDir.value = dir;51 52 return Find;53 };54 55 Find.setName = function(name) {56 if (elementName)57 elementName.value = name;58 59 return Find;60 };61 62 function load(prefix, callback) {63 var scripts = [];64 65 if (!window.load)66 scripts.push(prefix + '/assets/modules/load/load.js');67 68 if (!window.join)69 scripts.push(prefix + '/join/join.js');70 71 if (!window.rendy)72 scripts.push(prefix + '/assets/modules/rendy/lib/rendy.js');73 74 if (!scripts.length)75 after(prefix, callback);76 else77 loadScript(scripts, function() {78 after(prefix, callback);79 });80 }81 82 function after(prefix, callback) {83 var load = window.load,84 join = window.join,85 86 css = prefix + join([87 '/assets/css/style.css',88 '/assets/css/webfind.css'89 ]),90 91 loadTemplates = function() {92 var path = '/template/',93 pathTmpl = prefix + join([94 path + 'main.html',95 path + 'file.html',96 ]);97 98 load(pathTmpl, callback);99 };100 101 load.json(prefix + '/modules.json', function(error, remote) {102 if (error)103 console.log(error);104 else105 load.series(remote.concat(css), loadTemplates);106 });107 }108 109 function loadScript(srcs, callback) {110 var i = srcs.length,111 func = function() {112 --i;113 114 if (!i)115 callback();116 };117 118 srcs.forEach(function(src) {119 var element = document.createElement('script');120 121 element.src = src;122 element.addEventListener('load', func);123 124 document.body.appendChild(element);125 });126 }127 128 function addListeners(room) {129 var href = getHost(),130 FIVE_SECONDS = 5000;131 132 socket = io.connect(href + room, {133 'max reconnection attempts' : Math.pow(2, 32),134 'reconnection limit' : FIVE_SECONDS135 });136 137 socket.on(CHANNEL, onMessage);138 139 socket.on('connect', function() {140 console.log('webfind: connected\n');141 });142 143 socket.on('disconnect', function() {144 console.log('webfind: disconnected\n');145 });146 }147 148 function getHost() {149 var l = location,150 href = l.origin || l.protocol + '//' + l.host;151 152 return href;153 }154 155 function createElements(element) {156 var submit = function() {157 var name = elementName.value,158 dir = elementDir.value;159 160 if (!name)161 name = elementName.value = '*';162 163 if (!dir)164 dir = elementDir.value = '/';165 166 if (elementSearch.textContent === 'Stop') {167 elementSearch.textContent = 'Start';168 elementClear.disabled = false;169 170 socket.emit(CHANNEL, {171 stop: true172 });173 174 hideLoad();175 } else {176 elementResult.textContent = '';177 elementSearch.textContent = 'Stop';178 elementClear.disabled = true;179 180 socket.emit(CHANNEL, {181 name: name,182 dir: dir183 });184 185 showLoad();186 }187 },188 189 onEnter = function(event) {190 var ENTER = 13;191 192 if (event.keyCode === ENTER)193 submit();194 };195 196 element.innerHTML = TMPL_MAIN;197 198 elementSearch = element.querySelector('[data-name="webfind-button-search"]');199 elementClear = element.querySelector('[data-name="webfind-button-clear"]');200 elementName = element.querySelector('[data-name="webfind-name"]');201 elementDir = element.querySelector('[data-name="webfind-dir"]');202 elementResult = element.querySelector('[data-name="webfind-result"]');203 elementLoad = element.querySelector('[data-name="webfind-load"]');204 205 elementLoad.classList.add('webfind-load-' + (isSVG() ? 'svg' : 'gif'));206 207 elementSearch.addEventListener('click', submit);208 elementName.addEventListener('keydown', onEnter);209 elementDir.addEventListener('keydown', onEnter);210 211 elementClear.addEventListener('click', function() {212 elementResult.textContent = '';213 });214 }215 216 /**217 * check SVG SMIL animation support218 */219 function isSVG() {220 var ret, svgNode, name,221 create = document.createElementNS,222 SVG_URL = 'http://www.w3.org/2000/svg';223 224 if (create) {225 create = create.bind(document);226 svgNode = create(SVG_URL, 'animate');227 name = svgNode.toString();228 ret = /SVGAnimate/.test(name);229 }230 231 return ret;232 }233 234 function hideLoad() {235 elementLoad.classList.add('webfind-hide');236 }237 238 function showLoad() {239 elementLoad.classList.remove('webfind-hide');240 }241 242 function parseTemplates(templates) {243 var elMain, elFile,244 el = document.createElement('div');245 el.innerHTML = templates;246 247 elMain = el.querySelector('[data-name="webfind-template-main"]');248 elFile = el.querySelector('[data-name="webfind-template-file"]');249 250 TMPL_MAIN = elMain.innerHTML;251 TMPL_FILE = elFile.innerHTML;252 }253 254 function onMessage(data) {255 var el;256 257 if (data.error)258 console.log(data.error);259 else if (data.path) {260 el = document.createElement('li');261 262 el.innerHTML = rendy(TMPL_FILE, {263 name: data.path,264 type: data.type265 });266 267 el.setAttribute('data-name', 'js-' + data.path);268 269 elementResult.appendChild(el);270 } else if (data.done) {271 if (!elementResult.childNodes.length)272 elementResult.textContent = 'File not found.';273 274 elementSearch.textContent = 'Start';275 hideLoad();276 }277 }278 279 return Find;280 }281 ...

Full Screen

Full Screen

test.js

Source:test.js Github

copy

Full Screen

...88 logger('Incorrect birth date test', logs);89 // Successful submit test /////////////////////////////////////////////////////////90 var logs = [];91 // Clear and enter correct names92 await driver.elementClear(find.byValueKey('fname'));93 await driver.elementClear(find.byValueKey('lname'));94 await driver.elementSendKeys(find.byValueKey('fname'), 'John');95 await driver.elementSendKeys(find.byValueKey('lname'), 'Doe');96 // Choose day97 await driver.elementClick(find.byValueKey('dateField'));98 var today = new Date();99 await driver.elementClick(find.byText(String(today.getDate())));100 await driver.elementClick(find.byText('OK'));101 // Choose city102 await driver.elementClick(find.byValueKey('cityDropdown'));103 await driver.elementClick(find.byText('Artvin'));104 // Choose gender105 await driver.elementClick(find.byValueKey('genderDropdown'));106 await driver.elementClick(find.byText('Male'));107 // Choose vaccine108 await driver.elementClick(find.byValueKey('vaccineDropdown'));109 await driver.elementClick(find.byText('Moderna'));110 // Enter side effects111 await driver.elementClear(find.byValueKey('sideEffects'));112 await driver.elementSendKeys(find.byValueKey('sideEffects'), 'Not Applicable');113 // Submit114 try {115 // send button116 await driver.execute('flutter:waitFor', find.byValueKey('submit'));117 await driver.elementClick(find.byValueKey('submit'));118 logs.push("Send button was clicked");119 logs.push("TEST PASSED");120 }121 catch(err) {122 logs.push("Send button did not appear");123 logs.push("TEST FAILED");124 }125 logger('Successful submission test', logs);126 // Switch context /////////////////////////////////////////////////////////127 var logs = [];128 await driver.elementClear(find.byValueKey('fname'));129 await driver.elementClear(find.byValueKey('lname'));130 await driver.elementSendKeys(find.byValueKey('fname'), 'Jane');131 await driver.elementSendKeys(find.byValueKey('lname'), 'Maybe');132 await driver.switchContext('NATIVE_APP');133 await driver.background(0.7);134 await driver.switchContext('FLUTTER');135 try{136 assert.strictEqual(await driver.getElementText(find.byValueKey('fname')), 'Jane');137 assert.strictEqual(await driver.getElementText(find.byValueKey('lname')), 'Maybe');138 logs.push("Context Switched and text remained in fields");139 logs.push("TEST PASSED");140 }141 catch(err) {142 logs.push("Context switch did not work and text fields changed");143 logs.push("TEST FAILED");144 }145 logger('Context switch test', logs);146 // Orientation test /////////////////////////////////////////////////////////147 var logs = [];148 await driver.elementClick(find.byValueKey('orientation'));149 // Clear and enter correct names150 await driver.elementClear(find.byValueKey('fname'));151 await driver.elementClear(find.byValueKey('lname'));152 await driver.elementSendKeys(find.byValueKey('fname'), 'John');153 await driver.elementSendKeys(find.byValueKey('lname'), 'Doe');154 await driver.execute('flutter:scrollIntoView',find.byValueKey('dateField'), {alignment: 0.1})155 // Choose day156 await driver.elementClick(find.byValueKey('dateField'));157 var today = new Date();158 await driver.elementClick(find.byText(String(today.getDate())));159 await driver.elementClick(find.byText('OK'));160 await driver.execute('flutter:scrollIntoView',find.byValueKey('cityDropdown'), {alignment: 0.1}) 161 // Choose city162 await driver.elementClick(find.byValueKey('cityDropdown'));163 await driver.elementClick(find.byText('Adana'));164 await driver.execute('flutter:scrollIntoView',find.byValueKey('genderDropdown'), {alignment: 0.1}) 165 // Choose gender166 await driver.elementClick(find.byValueKey('genderDropdown'));167 await driver.elementClick(find.byText('Male'));168 await driver.execute('flutter:scrollIntoView',find.byValueKey('vaccineDropdown'), {alignment: 0.1}) 169 // Choose vaccine170 await driver.elementClick(find.byValueKey('vaccineDropdown'));171 await driver.elementClick(find.byText('Moderna'));172 await driver.execute('flutter:scrollIntoView',find.byValueKey('sideEffects'), {alignment: 0.1}) 173 // Enter side effects174 await driver.elementClear(find.byValueKey('sideEffects'));175 await driver.elementSendKeys(find.byValueKey('sideEffects'), 'Not Applicable');176 await driver.execute('flutter:scrollIntoView',find.byValueKey('submit'), {alignment: 0.1}) 177 await driver.elementClick(find.byValueKey('orientation'));178 // Submit179 try {180 // send button181 await driver.execute('flutter:waitFor', find.byValueKey('submit'));182 await driver.elementClick(find.byValueKey('submit'));183 logs.push("Send button was clicked with changed orientation");184 logs.push("TEST PASSED");185 }186 catch(err) {187 logs.push("Send button did not appear with changed orientation");188 logs.push("TEST FAILED");...

Full Screen

Full Screen

biatTabs.js

Source:biatTabs.js Github

copy

Full Screen

1import parametersComponent from '../resources/parametersComponent.js';2import blocksComponent from '../resources/blocksComponent.js';3import textComponent from '../resources/textComponent.js';4import categoriesComponent from './biatCategoriesComponent.js';5import attributesComponent from '../resources/categoriesComponent.js';6import outputComponent from './biatOutputComponent.js';7import importComponent from './biatImportComponent.js';8import aboutComponent from '../resources/aboutComponent.js';9let parametersDesc = [10 {name: 'isTouch', options:['Keyboard', 'Touch'], label:'Keyboard input or touch input?', desc:'The script can run on a desktop computer or a touch device. \nMinno does not auto-detect the input method. If you need a touch version and a keyboard version, create two different scripts with this tool.'},11 {name: 'isQualtrics', options:['Regular','Qualtrics'], label:'Regular script or Qualtrics?', desc: ['If you want this BIAT to run from Qualtrics, read ', m('a',{href: 'https://minnojs.github.io/minnojs-blog/qualtrics-biat/'}, 'this blog post '),'to see how.']},12 {name: 'practiceBlock', label: 'Practice Block', desc: 'Should the task start with a practice block?'},13 {name: 'remindError', label: 'Error feedback on incorrect responses', desc: 'Should we show error feedback?\nIt is recommended to show participants an error feedback on error responses.'},14 {name: 'showStimuliWithInst', label: 'Show Stimuli with Instructions', desc: 'Whether to show the stimuli of the IN categories at the beginning of the block.'},15 {name: 'base_url', label: 'Image\'s URL', desc: 'If your task has any images, enter here the path to that images folder.\nIt can be a full url, or a relative URL to the folder that will host this script.'},16 {istouch:false, isQualtrics:false, practiceBlock:false, showStimuliWithInst:false, remindError:false, base_url:{image:''}}17];18let blocksDesc = [19 {name: 'nMiniBlocks', label: 'Mini Blocks', desc: 'Each block can be separated to a number of mini-blocks, to reduce repetition of the same response in consecutive trials. The default, 1, means that we don\'t actually use mini blocks.'},20 {name: 'nTrialsPerMiniBlock', label: 'Trials in Mini Blocks', desc: '50% on the right, 50% left, 50% attributes, 50% categories.'},21 {name: 'nPracticeBlockTrials', label: 'Trials in Practice Block', desc:'Should be at least 8 trials'},22 {name: 'nCategoryAttributeBlocks', label: 'Blocks per focal category-attribute combination', desc: 'Number of blocks per focal category-attribute combination'},23 {name: 'focalAttribute', label: 'Focal Attribute', desc: 'Sets whether we use a certain focal attribute throughout the task, or both.', options: ['attribute1','attribute2','both']},24 {name: 'firstFocalAttribute', label: 'First Focal Attribute', desc: 'Sets what attribute appears first. Irrelevant if Focal Attribute is not \'both\'.', options: ['attribute1','attribute2','random']},25 {name: 'focalCategoryOrder', label: 'Focal Category Order', desc: 'If bySequence then we always start with the first category in the list as the first focal category.', options: ['bySequence','random']},26 {nMiniBlocks: 0, nTrialsPerMiniBlock: 0, nPracticeBlockTrials:0, nCategoryAttributeBlocks:0,27 focalAttribute: 'attribute1', firstFocalAttribute : 'random', focalCategoryOrder: 'random'}28];29let textDesc = [30 {name: 'instTemplate', nameTouch: 'instTemplateTouch',label:'Instructions'},31 {name: 'remindErrorText', nameTouch: 'remindErrorTextTouch' , label:'Screen\'s Bottom (error reminder)', desc:'We use this text to remind participants what happens on error. Replace this text if you do not require participants to correct their error responses (see General Parameters page).'},32 {name: 'leftKeyText', nameTouch:'leftKeyTextTouch',label:'Top-left text (about the left key)', desc: 'We use this text to remind participants what key to use for a left response.'},33 {name: 'rightKeyText', nameTouch:'rightKeyTextTouch',label:'Top-right text (about the right key)', desc: 'We use this text to remind participants what key to use for a right response.'},34 {name: 'orText', label:'Or', desc: 'We show this text in the combined blocks to separate between the two categories that use the same key.'},35 {name: 'finalText', nameTouch: 'finalTouchText' , label:'Text shown at the end of the task'},36 {remindErrorText:'', leftKeyText:'', rightKeyText:'', orText:'', instTemplate:'', finalText:''},37 {remindErrorTextTouch:'', leftKeyTextTouch:'', rightKeyTextTouch:'', instTemplateTouch:'', finalTouchText:''}38];39let elementClear = [{40 name : '',41 title : {42 media : {word : ''},43 css : {color:'#000000','font-size':'1em'},44 height : 4, 45 startStimulus : { 46 media : {word : ''},47 css : {color:'#000000','font-size':'1em'},48 height : 249 }50 },51 stimulusMedia : [], 52 stimulusCss : {color:'#000000','font-size':'1em'} }];53let attributesTabs = {54 'attribute1': {text: 'First Attribute'},55 'attribute2': {text: 'Second Attribute'}56};57let practiceTabs = {58 'practiceCategory1':{text: 'First Practice Category'},59 'practiceCategory2':{text: 'Second Practice Category'}60};61let tabs = {62 'parameters': {text: 'General parameters', component: parametersComponent, rowsDesc: parametersDesc},63 'blocks': {text: 'Blocks', component: blocksComponent, rowsDesc: blocksDesc},64 'practice': {65 text: 'Practice Block',66 component: attributesComponent,67 rowsDesc: elementClear,68 subTabs: practiceTabs,69 type: 'BIAT'70 },71 'categories': {text: 'Categories', component: categoriesComponent, rowsDesc: elementClear},72 'attributes': {73 text: 'Attributes',74 component: attributesComponent,75 rowsDesc: elementClear,76 subTabs: attributesTabs,77 type: 'BIAT'78 },79 'text': {text: 'Texts', component: textComponent, rowsDesc: textDesc},80 'output': {text: 'Complete', component: outputComponent, rowsDesc: blocksDesc},81 'import': {text: 'Import', component: importComponent},82 'about': {text: 'About', component: aboutComponent, rowsDesc: 'BIAT'}83};...

Full Screen

Full Screen

main.js

Source:main.js Github

copy

Full Screen

...43 await driver.elementClick(byText('ปิด'));44 });45 it('Log in wrong username', async function () {46 // this.timeout(30 * 1000);47 await driver.elementClear(usernameField);48 await driver.elementClear(passwordField);49 await driver.elementSendKeys(usernameField, "551502");50 await driver.elementSendKeys(passwordField, "551505");51 await driver.elementClick(loginButton);52 try {53 expect(await driver.getElementText(byText('ไม่พบข้อมูลชื่อผู้ใช้งาน'))).to.exist;54 await driver.elementClick(byText('ปิด'));55 } catch (e) {}56 });57 after(function () {58 driver.deleteSession();59 })60 });61}62const loginPass = function(opts) {63 before(async function () {64 this.timeout(50000 * 10000);65 driver = await wdio.remote(opts);66 usernameField = byValueKey('usernameTxt');67 passwordField = byValueKey('passwordTxt');68 loginButton = byValueKey('loginBtn')69 });70 beforeEach(function () {71 if (skip) {72 this.skip();73 }74 });75 afterEach(async function () {76 if (this.currentTest.state == 'failed') {77 var imgName = (this.currentTest.parent.title).replace(/ /g, "_");78 var screenshotPath = 'C:\\Users\\bmais\\Documents\\SeniorHomepro\\E-CatalogTest\\images\\login\\'79 await driver.saveScreenshot(screenshotPath + imgName + '.png');80 skip = true;81 }82 });83 describe('Login to pass', function() {84 it('Log in successful', async function () {85 this.timeout(50000);86 await driver.elementClear(usernameField);87 await driver.elementClear(passwordField);88 await driver.elementSendKeys(usernameField, "551503");89 await driver.elementSendKeys(passwordField, "551505");90 await driver.elementClick(loginButton);91 await driver.execute('flutter:waitForAbsent', loginButton);92 // expect(await driver.getElementText(byText('ประชาชื่น')), 'ประชาชื่น')93 });94 after(function () {95 driver.deleteSession();96 })97 });98}99module.exports = {100 loginFail,101 loginPass...

Full Screen

Full Screen

script.js

Source:script.js Github

copy

Full Screen

1const list = document.getElementById('lista-tarefas'); // lista ordenada2const botao = document.getElementById('criar-tarefa');// botão de criar3const limpar = document.getElementById('apaga-tudo'); // botão de limpar4const deleted = document.getElementById('remover-finalizados'); // botao de remover5const save = document.getElementById('salvar-tarefas'); // Botão de salvar6const up = document.getElementById('mover-cima'); // Subir item 7const down = document.getElementById('mover-baixo'); // Descer item8const remove = document.getElementById('remover-selecionado') // Remove item selecionado9// Fução para criar lista com o valor do Input10function createList() {11 const input = document.querySelector('#texto-tarefa');12 const texto = input.value;13 const create = document.createElement('li');14 create.innerHTML = texto;15 list.appendChild(create);16 clearInput();17}18// Função para apagar o valor retirado do Input19function clearInput() {20 document.getElementById('texto-tarefa').value = '';21}22// função para mudar o fundo para Cinza23function listColor(event) {24 const test = document.querySelector('.selected');25 if (test) {26 test.classList.remove('selected');27 }28 event.target.classList.add('selected');29}30const removeRisk = document.querySelector('#lista-tarefas');31removeRisk.addEventListener('dblclick', risk);32function risk(event) {33 const comp = document.querySelector('.completed');34 if (comp) {35 comp.classList.add('completed');36 }37 event.target.classList.toggle('completed');38}39function clear() {40 const elementClear = document.querySelectorAll('#lista-tarefas li');41 for (let i = 0; i < elementClear.length; i += 1) {42 elementClear[i].remove();43 }44}45function removerCompletos() {46 const removecomplete = document.querySelectorAll('.completed');47 for (let i = 0; i < removecomplete.length; i += 1) {48 removecomplete[i].remove();49 }50}51function elementToObject(itensText, itensCompleted) {52 return {53 content: itensText,54 class: itensCompleted };55}56function saveList() {57 removeToSave()58 const itens = document.querySelectorAll('#lista-tarefas li');59 const listItems = [];60 let itensList;61 for (let i = 0; i < itens.length; i += 1) {62 itensList = elementToObject(itens[i].innerText, itens[i].className);63 listItems.push(itensList);64 }65 localStorage.setItem('taskList', JSON.stringify(listItems));66}67function loadList(itensText, itensCompleted) {68 const newList = document.createElement('li');69 list.appendChild(newList);70 newList.innerText = itensText;71 newList.className = itensCompleted;72}73function moveUp() {74 const item = document.querySelector('.selected');75 if (!item) {76 return;77 }78 const position = item.previousSibling;79 if (position) {80 item.parentNode.insertBefore(item, position);81 }82}83function moveDown() {84 const item = document.querySelector('.selected');85 if (!item) {86 return;87 }88 const position = item.nextSibling;89 if (position) {90 position.after(item);91 }92}93function removeSelected() {94 const elementClear = document.querySelectorAll('.selected');95 for (let i = 0; i < elementClear.length; i += 1) {96 elementClear[i].remove();97 }98}99function removeToSave() {100 const selectedClear = document.querySelector('.selected');101 selectedClear.classList.remove('selected');102}103// Chamando a função104botao.addEventListener('click', createList);105list.addEventListener('click', listColor);106limpar.addEventListener('click', clear);107deleted.addEventListener('click', removerCompletos);108save.addEventListener('click', saveList);109up.addEventListener('click', moveUp);110down.addEventListener('click', moveDown);111remove.addEventListener('click', removeSelected);112window.onload = () => {113 let loading = localStorage.getItem('taskList');114 if (!loading) {115 return;116 } loading = JSON.parse(loading);117 for (let i = 0; i < loading.length; i += 1) {118 loadList(loading[i].content, loading[i].class);119 }120};...

Full Screen

Full Screen

clear.test.js

Source:clear.test.js Github

copy

Full Screen

1const uuid = require('uuid/v4');2const clear = require('../../../../src/core/actions/clear');3const eraser = require('../../../../src/utils/browser/eraser');4const logger = require('../../../../src/utils/logger');5const { MESSAGE_TYPE, CLEAR_ERR } = require('../../../../src/constants');6let state;7describe('clear action test suite', () => {8 beforeEach(() => {9 state = {10 browser: {11 getActiveElement: jest.fn(),12 elementClear: jest.fn(),13 execute: jest.fn(),14 },15 };16 });17 test('clear command with target type "input" should trigger the corresponding webdriver.io function to clear the currently active input element', async () => {18 const currentlyActiveElementId = uuid();19 state.browser.getActiveElement.mockResolvedValue({20 ELEMENT: currentlyActiveElementId,21 });22 state.browser.elementClear.mockResolvedValue(true);23 await clear(state, { args: { what: 'input' } });24 expect(state.browser.getActiveElement).toHaveBeenCalled();25 expect(state.browser.elementClear).toHaveBeenCalled();26 expect(state.browser.elementClear).toHaveBeenCalledWith(currentlyActiveElementId);27 expect(state.browser.execute).not.toHaveBeenCalled();28 });29 test('clear command with target type "text" should trigger the corresponding webdriver.io function to clear the currently active input element', async () => {30 const currentlyActiveElementId = uuid();31 state.browser.getActiveElement.mockResolvedValue({32 ELEMENT: currentlyActiveElementId,33 });34 await clear(state, { args: { what: 'text' } });35 expect(state.browser.getActiveElement).toHaveBeenCalled();36 expect(state.browser.elementClear).toHaveBeenCalled();37 expect(state.browser.elementClear).toHaveBeenCalledWith(currentlyActiveElementId);38 expect(state.browser.execute).not.toHaveBeenCalled();39 });40 test('clear command with target type "highlights" should execute the highlight erasor on the page to clear highlights from the page', async () => {41 await clear(state, { args: { what: 'highlights' } });42 expect(state.browser.getActiveElement).not.toHaveBeenCalled();43 expect(state.browser.elementClear).not.toHaveBeenCalled();44 expect(state.browser.execute).toHaveBeenCalled();45 expect(state.browser.execute).toHaveBeenCalledWith(eraser.eraseHighlights);46 });47 test('clear command with an unknown should return a rejected promise with a specific error message', async () => {48 logger.emitLogs = jest.fn();49 try {50 await clear(state, { args: { what: uuid() } });51 } catch (err) {52 expect(err).toBeTruthy();53 expect(err).toHaveProperty('message', 'Incorrect usage of command. Accepted parameters are, "text", "input" or "highlights"');54 expect(state.browser.getActiveElement).not.toHaveBeenCalled();55 expect(state.browser.elementClear).not.toHaveBeenCalled();56 expect(state.browser.execute).toHaveBeenCalled();57 expect(logger.emitLogs).toHaveBeenCalledWith({ message: CLEAR_ERR, type: MESSAGE_TYPE.ERROR });58 }59 });...

Full Screen

Full Screen

elementClear.js

Source:elementClear.js Github

copy

Full Screen

...12 * @alias browser.elementClear13 * @see https://w3c.github.io/webdriver/#dfn-element-clear14 * @param {string} elementId the id of an element returned in a previous call to Find Element(s)15 */16async function elementClear({ elementId }) {17 const elementHandle = await this.elementStore.get(elementId);18 if (!elementHandle) {19 throw utils_1.getStaleElementError(elementId);20 }21 const page = this.getPageHandle(true);22 await page.$eval('html', elementClear_1.default, elementHandle);23 return null;24}...

Full Screen

Full Screen

element-clear.js

Source:element-clear.js Github

copy

Full Screen

1import Endpoint from '..'2class ElementClear extends Endpoint {3 static create (req) {4 return new ElementClear([req.params.id])5 }6}7ElementClear.method = 'post'8ElementClear.url = '/session/:sid/element/:id/clear'...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriverio = require('webdriverio');2var options = {3 desiredCapabilities: {4 }5};6 .remote(options)7 .init()8 .setValue('#lst-ib', 'WebdriverIO')9 .elementClear('#lst-ib')10 .end();11var webdriverio = require('webdriverio');12var options = {13 desiredCapabilities: {14 }15};16 .remote(options)17 .init()18 .setValue('#lst-ib', 'WebdriverIO')19 .elementClear('#lst-ib')20 .end();21var webdriverio = require('webdriverio');22var options = {23 desiredCapabilities: {24 }25};26 .remote(options)27 .init()28 .setValue('#lst-ib', 'WebdriverIO')29 .elementClear('#lst-ib')30 .end();31var webdriverio = require('webdriverio');32var options = {33 desiredCapabilities: {34 }35};36 .remote(options)37 .init()38 .setValue('#lst-ib', 'WebdriverIO')39 .elementClear('#lst-ib')

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriverio = require('webdriverio');2var options = {3 desiredCapabilities: {4 }5};6 .remote(options)7 .init()8 .setValue('input[name="q"]','webdriverio')9 .elementClear('input[name="q"]')10 .end();

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('webdriver.io page', () => {2 it('should have the right title', () => {3 const input = $('input[type="search"]');4 input.setValue('WebdriverIO');5 input.clearValue();6 });7});8describe('webdriver.io page', () => {9 it('should have the right title', () => {10 const input = $('input[type="search"]');11 input.setValue('WebdriverIO');12 input.clearValue();13 });14});15describe('webdriver.io page', () => {16 it('should have the right title', () => {17 const input = $('input[type="search"]');18 input.setValue('WebdriverIO');19 input.clearValue();20 });21});22describe('webdriver.io page', () => {23 it('should have the right title', () => {24 const input = $('input[type="search"]');25 input.setValue('WebdriverIO');26 input.clearValue();27 });28});29describe('webdriver.io page', () => {30 it('should have the right title', () => {31 const input = $('input[type="search"]');32 input.setValue('WebdriverIO');33 input.clearValue();34 });35});36describe('webdriver.io page', () => {37 it('should have the right title', () => {38 const input = $('input[type="search"]');39 input.setValue('WebdriverIO');

Full Screen

Using AI Code Generation

copy

Full Screen

1client.elementClear(selector, function(err, res) {2 if(err) {3 console.log(err);4 } else {5 console.log(res);6 }7});8browser.elementClear(selector, function(err, res) {9 if(err) {10 console.log(err);11 } else {12 console.log(res);13 }14});15browser.elementClear(selector).then(function(res) {16 console.log(res);17});18cy.elementClear(selector).then(function(res) {19 console.log(res);20});21testController.elementClear(selector).then(function(res) {22 console.log(res);23});24gauge.elementClear(selector, function(err, res) {25 if(err) {26 console.log(err);27 } else {28 console.log(res);29 }30});31page.elementClear(selector).then(function(res) {32 console.log(res);33});34page.elementClear(selector).then(function(res) {35 console.log(res);36});37browser.elementClear(selector).then(function(res) {38 console.log(res);39});40browser.elementClear(selector).then(function(res) {41 console.log(res);42});43browser.elementClear(selector).then(function(res) {44 console.log(res);45});46browser.elementClear(selector).then(function(res) {47 console.log(res);48});49client.elementClick(selector, function(err, res) {50 if(err) {51 console.log(err);52 } else {53 console.log(res);54 }55});56browser.elementClick(selector, function(err, res) {57 if(err) {58 console.log(err);59 } else {60 console.log(res);61 }62});

Full Screen

Using AI Code Generation

copy

Full Screen

1describe("Clear the text in the input field", function() {2 it("Should clear the text in the input field", function() {3 var inputField = $('input[name="q"]');4 inputField.setValue("WebdriverIO");5 inputField.clearValue();6 browser.pause(2000);7 });8});

Full Screen

WebdriverIO Tutorial

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.

Chapters

  1. 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.

  2. Selenium Automation With WebdriverIO - Read more about automation testing with WebdriverIO and how it supports both browsers and mobile devices.

  3. 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?

  4. 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.

  5. 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.

  6. 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.

  7. Handling Dropdown In Selenium - Learn more about handling dropdowns and how it's important while performing automated browser testing.

  8. 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.

  9. JavaScript Testing with Selenium and WebdriverIO - Speed up your Javascript testing with Selenium and WebdriverIO.

  10. 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.

Run Webdriverio automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful