Best JavaScript code snippet using qawolf
hs-add-field.js
Source:hs-add-field.js
1/*2* HSAddField Plugin3* @version: 2.0.1 (Jul, 31 Nov 2021)4* @author: HtmlStream5* @event-namespace: .HSAddField6* @license: Htmlstream Libraries (https://htmlstream.com/)7* Copyright 2021 Htmlstream8*/9const dataAttributeName = 'data-hs-add-field-options'10const defaults = {11 createTrigger: '.js-create-field',12 deleteTrigger: '.js-delete-field',13 limit: 5,14 defaultCreated: 1,15 nameSeparator: '_',16 addedField: function () {17 },18 deletedField: function () {19 }20}21export default class HSAddField {22 constructor(el, options, id) {23 this.collection = []24 const that = this25 let elems26 if (el instanceof HTMLElement) {27 elems = [el]28 } else if (el instanceof Object) {29 elems = el30 } else {31 elems = document.querySelectorAll(el)32 }33 for (let i = 0; i < elems.length; i += 1) {34 that.addToCollection(elems[i], options, id || elems[i].id)35 }36 if (!that.collection.length) {37 return false38 }39 // initialization calls40 that._init()41 return this42 }43 _init() {44 const that = this;45 for (let i = 0; i < that.collection.length; i += 1) {46 let _$el47 let _options48 if (that.collection[i].hasOwnProperty('$initializedEl')) {49 continue50 }51 _$el = that.collection[i].$el;52 _options = that.collection[i].options53 _options.flags = {54 name: 'data-name',55 delete: 'data-hs-add-field-delete'56 }57 _options.fieldsCount = 058 _options.fieldsCount = _options.defaultCreated;59 _options.tempalte = document.querySelector(_options.template)60 _options.contaienr = _$el.querySelector(_options.container)61 for (var key = 0; key < _options.defaultCreated; key++) {62 that.addField(_$el, _options)63 }64 _$el.addEventListener('click', (e) => {65 if (e.target.closest(_options.createTrigger)) {66 that.addField(_$el, _options)67 } else if (e.target.closest(_options.deleteTrigger)) {68 that.deleteField(_$el, _options, e.target.closest(_options.deleteTrigger).getAttribute(_options.flags.delete))69 }70 })71 }72 }73 addField($el, settings) {74 const that = this75 if (settings.fieldsCount < settings.limit) {76 const field = settings.tempalte.cloneNode(true)77 field.removeAttribute('id')78 field.style.display = null79 settings.contaienr.appendChild(field)80 that.updateFieldsCount($el, settings);81 that.renderName($el, settings);82 that.renderKeys($el, settings);83 that.toggleCreateButton($el, settings);84 settings.addedField(field);85 }86 }87 deleteField($el, settings, index) {88 const that = this89 if (settings.fieldsCount > 0) {90 settings.contaienr.childNodes[index].parentNode.removeChild(settings.contaienr.childNodes[index])91 that.updateFieldsCount($el, settings);92 that.renderName($el, settings);93 that.renderKeys($el, settings);94 that.toggleCreateButton($el, settings);95 settings.deletedField()96 }97 }98 renderName($el, settings) { 99 settings.contaienr.childNodes.forEach((el, key) => {100 if (el.nodeName === '#text') return 101 const field = el.querySelector(`[${settings.flags.name}]`)102 if (!field) return103 field.setAttribute('name', `${field.getAttribute('data-name')}${settings.nameSeparator}${key}`)104 })105 }106 renderKeys($el, settings) {107 settings.contaienr.childNodes.forEach((el, key) => {108 if (el.nodeName === '#text') return 109 const deleteTrigger = el.querySelector(settings.deleteTrigger)110 deleteTrigger ? deleteTrigger.setAttribute(settings.flags.delete, key) : null111 })112 }113 updateFieldsCount($el, settings) {114 settings.fieldsCount = settings.contaienr.childNodes.length115 }116 toggleCreateButton($el, settings) {117 const createTrigger = $el.querySelector(settings.createTrigger)118 if (settings.fieldsCount === settings.limit) {119 createTrigger.style.display = 'none'120 } else {121 createTrigger.style.display = null122 }123 }124 addToCollection(item, options, id) {125 this.collection.push({126 $el: item,127 id: id || null,128 options: Object.assign(129 {},130 defaults,131 item.hasAttribute(dataAttributeName)132 ? JSON.parse(item.getAttribute(dataAttributeName))133 : {},134 options,135 ),136 })137 }138 getItem(item) {139 if (typeof item === 'number') {140 return this.collection[item].$initializedEl;141 } else {142 return this.collection.find(el => {143 return el.id === item;144 }).$initializedEl;145 }146 }...
DeleteTrigger.js
Source:DeleteTrigger.js
1( function ( mw, $, wf ) {2 workflows.ui.dialog.DeleteTrigger = function( cfg ) {3 workflows.ui.dialog.DeleteTrigger.super.call( this, cfg );4 this.key = cfg.key;5 };6 OO.inheritClass( workflows.ui.dialog.DeleteTrigger, OO.ui.ProcessDialog );7 workflows.ui.dialog.DeleteTrigger.static.name = 'deleteTrigger';8 workflows.ui.dialog.DeleteTrigger.static.title = mw.message( 'workflows-ui-trigger-delete-dialog-title' ).text();9 workflows.ui.dialog.DeleteTrigger.static.actions = [10 {11 action: 'delete',12 label: mw.message( 'workflows-ui-trigger-action-delete' ).text(),13 flags: [ 'primary', 'destructive' ]14 },15 {16 label: mw.message( 'workflows-ui-action-cancel' ).text(),17 flags: 'safe'18 }19 ];20 workflows.ui.dialog.DeleteTrigger.prototype.initialize = function () {21 workflows.ui.dialog.DeleteTrigger.super.prototype.initialize.apply( this, arguments );22 var notice = new OO.ui.LabelWidget( {23 label: mw.message( 'workflows-ui-trigger-delete-prompt', this.key ).text()24 } );25 var panel = new OO.ui.PanelLayout( {26 $content: notice.$element,27 padded: true28 } );29 this.$body.append( panel.$element );30 };31 workflows.ui.dialog.DeleteTrigger.prototype.showErrors = function( errors ) {32 workflows.ui.dialog.DeleteTrigger.parent.prototype.showErrors.call( this, errors );33 this.updateSize();34 };35 workflows.ui.dialog.DeleteTrigger.prototype.getActionProcess = function ( action ) {36 return workflows.ui.dialog.DeleteTrigger.parent.prototype.getActionProcess.call( this, action ).next(37 function() {38 if ( action === 'delete' ) {39 var dfd = $.Deferred();40 this.pushPending();41 workflows.triggers.delete( this.key ).done( function() {42 window.location.reload();43 } ).fail( function() {44 this.popPending();45 dfd.reject( mw.message( 'workflows-ui-triggers-error-delete-fail' ).text() );46 }.bind( this ) );47 return dfd.promise();48 }49 }, this50 );51 };52 workflows.ui.dialog.DeleteTrigger.prototype.onDismissErrorButtonClick = function () {53 this.hideErrors();54 this.updateSize();55 };56 workflows.ui.dialog.DeleteTrigger.prototype.getBodyHeight = function () {57 if ( !this.$errors.hasClass( 'oo-ui-element-hidden' ) ) {58 return this.$element.find( '.oo-ui-processDialog-errors' )[0].scrollHeight;59 }60 return 80;61 };...
Body.js
Source:Body.js
1// @flow2import * as React from 'react';3import { getTableFieldValue, scrollToTop } from './helpers';4import { Table } from './wrappers';5import Button from '../Button';6import { NO_OP } from '../helpers';7export type Props = {8 actionsLabel: number | string | React.Element<any> | Array<any>,9 updateTrigger: number | string | React.Element<any> | Array<any>,10 deleteTrigger: number | string | React.Element<any> | Array<any>,11 fields: Array<Object>,12 items: Array<Object>,13 onDeleteClick: Function,14 onUpdateClick: Function,15};16const Body = (props: Props): React$Element<any> => {17 const {18 fields,19 items,20 onDeleteClick,21 onUpdateClick,22 actionsLabel,23 updateTrigger,24 deleteTrigger,25 } = props;26 return (27 <Table.Body>28 {items.map((item) => (29 <Table.Row key={item.id}>30 {fields.map((field) => (31 <Table.Cell key={field.name}>32 <Table.CellLabel>{field.label}</Table.CellLabel>33 {getTableFieldValue(field, item)}34 </Table.Cell>35 ))}36 {(updateTrigger || deleteTrigger) && (37 <Table.Cell>38 <Table.CellLabel>{actionsLabel}</Table.CellLabel>39 {updateTrigger && (40 <Button41 modifiers="primary"42 onClick={() => {43 onUpdateClick(item);44 scrollToTop();45 }}46 >47 {updateTrigger}48 </Button>49 )}{' '}50 {deleteTrigger && (51 <Button52 modifiers="negative"53 onClick={() => {54 onDeleteClick(item);55 scrollToTop();56 }}57 >58 {deleteTrigger}59 </Button>60 )}61 </Table.Cell>62 )}63 </Table.Row>64 ))}65 </Table.Body>66 );67};68Body.defaultProps = {69 fields: ([]: Array<Object>),70 items: ([]: Array<Object>),71 actionsLabel: '',72 onDeleteClick: NO_OP,73 onUpdateClick: NO_OP,74 updateTrigger: null,75 deleteTrigger: null,76};...
Action_WakeUp.gs
Source:Action_WakeUp.gs
1class Action_WakeUp extends Action {2 execGet() {3 deleteTrigger(goingToBed_In15Minutes.name);4 deleteTrigger(goingToBed_In30Minutes.name);5 deleteTrigger(goingToBed_In120Minutes.name);6 return undefined;7 }8 getParameterName() {9 return PARAM_WAKEUP;10 }11}12const PARAM_WAKEUP = 'wakeUp';13function createSchedule_wakeUp() {14 createTrigger(wakeUp_In10Minutes.name, 10);15}16function wakeUp_In10Minutes() {17 deleteTrigger(goingToBed_In15Minutes.name);18 deleteTrigger(goingToBed_In30Minutes.name);19 deleteTrigger(goingToBed_In120Minutes.name);20 deleteTrigger(arguments.callee.name);...
Using AI Code Generation
1const { deleteTrigger } = require("qawolf");2const { createTrigger } = require("qawolf");3const { create } = require("qawolf");4const { select } = require("qawolf");5const { click } = require("qawolf");6const { type } = require("qawolf");7const { press } = require("qawolf");8const { url } = require("qawolf");9const { openBrowser } = require("qawolf");10const { closeBrowser } = require("qawolf");11const { launch } = require("qawolf");12const { browserContext } = require("qawolf");13const { page } = require("qawolf");14const { context } = require("qawolf");15const { $ } = require("qawolf");16const { $$ } = require("qawolf");17const { waitFor } = require("qawolf");18const { waitForNavigation } = require("qawolf");19const { waitForSelector } = require("qawolf");20const { waitForText } = require("qawolf");21const { waitForURL } = require("qawolf");22const { waitForXPath } = require("qawolf");
Using AI Code Generation
1const { deleteTrigger } = require('qawolf');2deleteTrigger('test.js');3const { deleteTrigger } = require('qawolf');4deleteTrigger('test.js');5const { deleteTrigger } = require('qawolf');6deleteTrigger('test.js');7const { deleteTrigger } = require('qawolf');8deleteTrigger('test.js');9const { deleteTrigger } = require('qawolf');10deleteTrigger('test.js');11const { deleteTrigger } = require('qawolf');12deleteTrigger('test.js');13const { deleteTrigger } = require('qawolf');14deleteTrigger('test.js');15const { deleteTrigger } = require('qawolf');16deleteTrigger('test.js');17const { deleteTrigger } = require('qawolf');18deleteTrigger('test.js');19const { deleteTrigger } = require('qawolf');20deleteTrigger('test.js');21const { deleteTrigger } = require('qawolf');22deleteTrigger('test.js');23const { deleteTrigger } = require('qawolf');24deleteTrigger('test.js');25const { deleteTrigger } = require('qawolf');26deleteTrigger('test.js');27const { deleteTrigger } = require('qawolf');28deleteTrigger('test.js');
Using AI Code Generation
1const { deleteTrigger } = require("qawolf");2const { trigger } = require("./trigger");3deleteTrigger(trigger);4const { createTrigger } = require("qawolf");5module.exports.trigger = createTrigger({6 { name: "click", selector: "input[name=\"q\"]" },7 { name: "type", selector: "input[name=\"q\"]", value: "test" },8 { name: "type", selector: "input[name=\"q\"]", value: "ing" },9 { name: "click", selector: "input[name=\"btnK\"]" }10});11const { deleteAllTriggers } = require("qawolf");12deleteAllTriggers();
Using AI Code Generation
1const { deleteTrigger } = require("qawolf");2(async () => {3 await deleteTrigger("trigger_id");4})();5const { deleteTrigger } = require("qawolf");6(async () => {7 await deleteTrigger("trigger_id");8})();9const { deleteTrigger } = require("qawolf");10(async () => {11 await deleteTrigger("trigger_id");12})();13const { deleteTrigger } = require("qawolf");14(async () => {15 await deleteTrigger("trigger_id");16})();17const { deleteTrigger } = require("qawolf");18(async () => {19 await deleteTrigger("trigger_id");20})();21const { deleteTrigger } = require("qawolf");22(async () => {23 await deleteTrigger("trigger_id");24})();25const { deleteTrigger } = require("qawolf");26(async () => {27 await deleteTrigger("trigger_id");28})();29const { deleteTrigger } = require("qawolf");30(async () => {31 await deleteTrigger("trigger_id");32})();33const { deleteTrigger } = require("qawolf");34(async () => {35 await deleteTrigger("trigger_id");36})();37const { deleteTrigger } = require("qawolf");38(async () => {39 await deleteTrigger("trigger_id");40})();41const { deleteTrigger } = require("qawolf");42(async () => {43 await deleteTrigger("trigger_id");44})();45const { deleteTrigger } = require("qawolf");46(async () => {47 await deleteTrigger("trigger_id");48})();
Using AI Code Generation
1const { deleteTrigger } = require('qawolf');2const { browserName } = require('qawolf');3const { createTrigger } = require('qawolf');4const { browserName } = require('qawolf');5const { createTrigger } = require('qawolf');6const { browserName } = require('qawolf');7const { deleteTrigger } = require('qawolf');8const { browserName } = require('qawolf');9const { deleteTrigger } = require('qawolf');10const { browserName } = require('qawolf');11const { createTrigger } = require('qawolf');12const { browserName } = require('qawolf');13const { createTrigger } = require('qawolf');14const { browserName } = require('qawolf');15const { deleteTrigger } = require('qawolf');16const { browserName } = require('qawolf');17const { deleteTrigger } = require('qawolf');18const { browserName } = require('qawolf');19const { createTrigger } = require('qawolf');20const { browserName } = require('qawolf');21const { createTrigger } = require('qawolf');22const { browserName } = require('qawolf');23const { deleteTrigger } = require('qawolf');24const { browserName } = require('qawolf');25const { deleteTrigger } = require('qawolf');26const { browserName } = require('qawolf');27const { createTrigger } = require('qawolf');28const { browserName } = require('qawolf');
Using AI Code Generation
1import { deleteTrigger, launch } from 'qawolf';2import { test } from 'qawolf';3test.describe('test', () => {4 test.beforeEach(async ({ browser }) => {5 const context = await browser.newContext();6 const page = await context.newPage();7 await page.click('#gb_70');8 await page.fill('#identifierId', 'test');9 await page.press('#identifierId', 'Enter');10 await page.fill('#password > div.aCsJod.oJeWuf > div > div.Xb9hP > input', 'test');11 await page.press('#password > div.aCsJod.oJeWuf > div > div.Xb9hP > input', 'Enter');12 await page.click('#submit_approve_access');13 await page.click('#yDmH0d > div > c-wiz > div
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!