How to use el1.click method in Appium Xcuitest Driver

Best JavaScript code snippet using appium-xcuitest-driver

namespace-test.js

Source:namespace-test.js Github

copy

Full Screen

1/*global bean:true, buster:true, Syn:true, assert:true, defer:true, features:true, globalSetUp:true, globalTearDown:true*/2buster.testCase('namespaces', {3 'setUp': globalSetUp4 , 'tearDown': globalTearDown5 , 'should be able to name handlers': {6 'setUp': function () {7 var self = this8 this.runTest = function (done, regFn) {9 var el1 = self.byId('foo')10 , trigger = self.trigger()11 , spy = self.spy()12 trigger.after(function () {13 assert.equals(spy.callCount, 1, 'triggered click event')14 done()15 })16 regFn(el1, trigger.wrap(spy))17 Syn.click(el1)18 }19 }20 , 'on()': function (done) {21 this.runTest(done, function (el1, wrappedSpy) {22 bean.on(el1, 'click.fat', wrappedSpy)23 })24 }25 , 'add()': function (done) {26 this.runTest(done, function (el1, wrappedSpy) {27 bean.add(el1, 'click.fat', wrappedSpy)28 })29 }30 }31 , 'should be able to add multiple handlers under the same namespace to the same element': {32 'setUp': function () {33 var self = this34 this.runTest = function (done, regFn) {35 var el1 = self.byId('foo')36 , trigger = self.trigger()37 , spy1 = self.spy()38 , spy2 = self.spy()39 trigger.after(function () {40 assert.equals(spy1.callCount, 1, 'triggered click event')41 assert.equals(spy2.callCount, 1, 'triggered click event')42 done()43 })44 regFn(el1, trigger.wrap(spy1), trigger.wrap(spy2))45 Syn.click(el1)46 }47 }48 , 'on()': function (done) {49 this.runTest(done, function (el1, wrappedSpy1, wrappedSpy2) {50 bean.on(el1, 'click.fat', wrappedSpy1)51 bean.on(el1, 'click.fat', wrappedSpy2)52 })53 }54 , 'add()': function (done) {55 this.runTest(done, function (el1, wrappedSpy1, wrappedSpy2) {56 bean.add(el1, 'click.fat', wrappedSpy1)57 bean.add(el1, 'click.fat', wrappedSpy2)58 })59 }60 }61 , 'should be able to fire an event without handlers': function () {62 var el1 = this.byId('foo')63 bean.fire(el1, 'click.fat')64 assert(true, 'fire namespaced event with no handlers (no exception)')65 }66 , 'should be able to target namespaced event handlers with fire': {67 'setUp': function () {68 var self = this69 this.runTest = function (done, regFn) {70 var el1 = self.byId('foo')71 , trigger = self.trigger()72 , spy1 = self.spy()73 , spy2 = self.spy()74 trigger.after(function () {75 assert.equals(spy1.callCount, 1, 'triggered click event (namespaced)')76 assert.equals(spy2.callCount, 0, 'should not trigger click event (plain)')77 done()78 })79 regFn(el1, trigger.wrap(spy1), trigger.wrap(spy2))80 bean.fire(el1, 'click.fat')81 }82 }83 , 'on()': function (done) {84 this.runTest(done, function (el1, wrappedSpy1, wrappedSpy2) {85 bean.on(el1, 'click.fat', wrappedSpy1)86 bean.on(el1, 'click', wrappedSpy2)87 })88 }89 , 'add()': function (done) {90 this.runTest(done, function (el1, wrappedSpy1, wrappedSpy2) {91 bean.add(el1, 'click.fat', wrappedSpy1)92 bean.add(el1, 'click', wrappedSpy2)93 })94 }95 }96 // changed in 0.5 so this doesn't fire, namespaces need to match97 , 'should not be able to target multiple namespaced event handlers with fire': {98 'setUp': function () {99 var self = this100 this.runTest = function (done, regFn) {101 var el1 = self.byId('foo')102 , spy1 = self.spy()103 , spy2 = self.spy()104 , spy3 = self.spy()105 regFn(el1, spy1, spy2, spy3)106 bean.fire(el1, 'click.fat.ded')107 defer(function () {108 assert.equals(spy1.callCount, 0, 'should not trigger click event (namespaced)')109 assert.equals(spy2.callCount, 0, 'should not trigger click event (namespaced)')110 assert.equals(spy3.callCount, 0, 'should not trigger click event (plain)')111 done()112 })113 }114 }115 , 'on()': function (done) {116 this.runTest(done, function (el1, wrappedSpy1, wrappedSpy2, wrappedSpy3) {117 bean.on(el1, 'click.fat', wrappedSpy1)118 bean.on(el1, 'click.ded', wrappedSpy2)119 bean.on(el1, 'click', wrappedSpy3)120 })121 }122 , 'add()': function (done) {123 this.runTest(done, function (el1, wrappedSpy1, wrappedSpy2, wrappedSpy3) {124 bean.add(el1, 'click.fat', wrappedSpy1)125 bean.add(el1, 'click.ded', wrappedSpy2)126 bean.add(el1, 'click', wrappedSpy3)127 })128 }129 }130 , 'should be able to remove handlers based on name': {131 'setUp': function () {132 var self = this133 this.runTest = function (done, regFn) {134 var el1 = self.byId('foo')135 , trigger = self.trigger()136 , spy1 = self.spy()137 , spy2 = self.spy()138 trigger.after(function () {139 assert.equals(spy1.callCount, 0, 'should not trigger click event (namespaced)')140 assert.equals(spy2.callCount, 1, 'triggered click event (plain)')141 done()142 })143 regFn(el1, trigger.wrap(spy1), trigger.wrap(spy2))144 bean.remove(el1, 'click.ded')145 Syn.click(el1)146 }147 }148 , 'on()': function (done) {149 this.runTest(done, function (el1, wrappedSpy1, wrappedSpy2) {150 bean.on(el1, 'click.ded', wrappedSpy1)151 bean.on(el1, 'click', wrappedSpy2)152 })153 }154 , 'add()': function (done) {155 this.runTest(done, function (el1, wrappedSpy1, wrappedSpy2) {156 bean.add(el1, 'click.ded', wrappedSpy1)157 bean.add(el1, 'click', wrappedSpy2)158 })159 }160 }161 // changed in 0.5 so this doesn't remove, namespaces need to match162 , 'should not be able to remove multiple handlers based on name': {163 'setUp': function () {164 var self = this165 this.runTest = function (done, regFn) {166 var el1 = self.byId('foo')167 , trigger = self.trigger()168 , spy1 = self.spy()169 , spy2 = self.spy()170 , spy3 = self.spy()171 trigger.after(function () {172 assert.equals(spy1.callCount, 1, 'triggered click event (namespaced)')173 assert.equals(spy2.callCount, 1, 'triggered click event (namespaced)')174 assert.equals(spy3.callCount, 1, 'triggered click event (plain)')175 done()176 })177 regFn(el1, trigger.wrap(spy1), trigger.wrap(spy2), trigger.wrap(spy3))178 bean.remove(el1, 'click.ded.fat')179 Syn.click(el1)180 }181 }182 , 'on()': function (done) {183 this.runTest(done, function (el1, wrappedSpy1, wrappedSpy2, wrappedSpy3) {184 bean.on(el1, 'click.fat', wrappedSpy1)185 bean.on(el1, 'click.ded', wrappedSpy2)186 bean.on(el1, 'click', wrappedSpy3)187 })188 }189 , 'add()': function (done) {190 this.runTest(done, function (el1, wrappedSpy1, wrappedSpy2, wrappedSpy3) {191 bean.add(el1, 'click.fat', wrappedSpy1)192 bean.add(el1, 'click.ded', wrappedSpy2)193 bean.add(el1, 'click', wrappedSpy3)194 })195 }196 }197 , 'should be able to add multiple custom events to a single handler and call them individually': {198 'setUp': function () {199 var self = this200 this.runTest = function (done, regFn) {201 var el1 = self.byId('foo')202 , trigger = self.trigger()203 , spy = self.spy()204 trigger.after(function () {205 assert.equals(spy.callCount, 2, 'triggered custom event')206 assert.equals(spy.firstCall.args[0], '1', 'expected array argument')207 assert.equals(spy.secondCall.args[0], '2', 'expected array argument')208 done()209 })210 regFn(el1, trigger.wrap(spy))211 bean.fire(el1, 'fat.test1', ['1'])212 bean.fire(el1, 'fat.test2', ['2'])213 }214 }215 , 'on()': function (done) {216 this.runTest(done, function (el1, wrappedSpy) {217 bean.on(el1, 'fat.test1 fat.test2', wrappedSpy)218 })219 }220 , 'add()': function (done) {221 this.runTest(done, function (el1, wrappedSpy) {222 bean.add(el1, 'fat.test1 fat.test2', wrappedSpy)223 })224 }225 }226 227 , 'should be able to fire an event if the fired namespace is within the event namespace range': {228 'setUp': function () {229 var self = this230 this.runTest = function (done, regFn) {231 var el1 = self.byId('foo')232 , trigger = self.trigger()233 , spy = self.spy()234 trigger.after(function () {235 assert.equals(spy.callCount, 4, 'triggered custom event')236 assert.equals(spy.firstCall.args[0], '1', 'expected array argument')237 assert.equals(spy.secondCall.args[0], '2', 'expected array argument')238 assert.equals(spy.thirdCall.args[0], '3', 'expected array argument')239 assert.equals(spy.lastCall.args[0], '3', 'expected array argument')240 done()241 })242 regFn(el1, trigger.wrap(spy))243 bean.fire(el1, 'fat.test1', ['1'])244 bean.fire(el1, 'fat.test2', ['2'])245 bean.fire(el1, 'fat.foo', ['3'])246 }247 }248 , 'on()': function (done) {249 this.runTest(done, function (el1, wrappedSpy) {250 bean.on(el1, 'fat.test1.foo fat.test2.foo', wrappedSpy)251 })252 }253 , 'add()': function (done) {254 this.runTest(done, function (el1, wrappedSpy) {255 bean.add(el1, 'fat.test1.foo fat.test2.foo', wrappedSpy)256 })257 }258 }259 , 'should be able to fire multiple events and fire them regardless of the order of the namespaces': {260 'setUp': function () {261 var self = this262 this.runTest = function (done, regFn) {263 var el1 = self.byId('foo')264 , trigger = self.trigger()265 , spy = self.spy()266 trigger.after(function () {267 assert.equals(spy.callCount, 4, 'triggered custom event')268 assert.equals(spy.firstCall.args[0], '1', 'expected array argument')269 assert.equals(spy.secondCall.args[0], '1', 'expected array argument')270 assert.equals(spy.thirdCall.args[0], '2', 'expected array argument')271 assert.equals(spy.lastCall.args[0], '2', 'expected array argument')272 done()273 })274 regFn(el1, trigger.wrap(spy))275 bean.fire(el1, 'fat.test.foo', ['1'])276 bean.fire(el1, 'fat.foo.test', ['2'])277 }278 }279 , 'on()': function (done) {280 this.runTest(done, function (el1, wrappedSpy) {281 bean.on(el1, 'fat.test.foo fat.foo.test', wrappedSpy)282 })283 }284 , 'add()': function (done) {285 this.runTest(done, function (el1, wrappedSpy) {286 bean.add(el1, 'fat.test.foo fat.foo.test', wrappedSpy)287 })288 }289 }290 291 , 'should only fire an event if the fired namespaces is within the event namespace or if the event namespace is within the fired namespace': {292 'setUp': function () {293 var self = this294 this.runTest = function (done, regFn) {295 var el1 = self.byId('foo')296 , trigger = self.trigger()297 , spy = self.spy()298 trigger.after(function () {299 assert.equals(spy.callCount, 5, 'triggered custom event')300 assert.equals(spy.firstCall.args[0], '1', 'expected array argument')301 assert.equals(spy.secondCall.args[0], '1', 'expected array argument')302 assert.equals(spy.thirdCall.args[0], '2', 'expected array argument')303 assert.equals(spy.getCall(3).args[0], '2', 'expected array argument')304 assert.equals(spy.getCall(4).args[0], '3', 'expected array argument')305 done()306 })307 regFn(el1, trigger.wrap(spy))308 bean.fire(el1, 'fat.test.foo', ['1'])309 bean.fire(el1, 'fat.foo.test', ['2'])310 bean.fire(el1, 'fat.test.ded', ['3'])311 }312 }313 , 'on()': function (done) {314 this.runTest(done, function (el1, wrappedSpy) {315 bean.on(el1, 'fat.test.foo.ded fat.foo.test fat.ded', wrappedSpy)316 })317 }318 , 'add()': function (done) {319 this.runTest(done, function (el1, wrappedSpy) {320 bean.add(el1, 'fat.test.foo.ded fat.foo.test fat.ded', wrappedSpy)321 })322 }323 }...

Full Screen

Full Screen

events.test.js

Source:events.test.js Github

copy

Full Screen

1/* eslint-env qunit */2import * as Events from '../../src/js/utils/events.js';3import document from 'global/document';4import log from '../../src/js/utils/log.js';5QUnit.module('Events');6QUnit.test('should add and remove an event listener to an element', function(assert) {7 assert.expect(1);8 const el = document.createElement('div');9 const listener = function() {10 assert.ok(true, 'Click Triggered');11 };12 Events.on(el, 'click', listener);13 // 1 click14 Events.trigger(el, 'click');15 Events.off(el, 'click', listener);16 // No click should happen.17 Events.trigger(el, 'click');18});19QUnit.test('should add and remove multiple event listeners to an element with a single call', function(assert) {20 assert.expect(6);21 const el = document.createElement('div');22 const listener = function() {23 assert.ok(true, 'Callback triggered');24 };25 Events.on(el, ['click', 'event1', 'event2'], listener);26 Events.trigger(el, 'click');27 Events.trigger(el, 'click');28 Events.off(el, 'click', listener);29 // No click should happen.30 Events.trigger(el, 'click');31 Events.trigger(el, 'event1');32 Events.trigger(el, 'event1');33 Events.off(el, 'event1', listener);34 // No event1 should happen.35 Events.trigger(el, 'event1');36 Events.trigger(el, 'event2');37 Events.trigger(el, 'event2');38 Events.off(el, 'event2', listener);39 // No event2 should happen.40 Events.trigger(el, 'event2');41 Events.off(el, ['click', 'event1', 'event2'], listener);42});43QUnit.test('should be possible to pass data when you trigger an event', function(assert) {44 assert.expect(6);45 const el = document.createElement('div');46 const fakeData1 = 'Fake Data 1';47 const fakeData2 = {txt: 'Fake Data 2'};48 const listener = function(evt, hash) {49 assert.ok(true, 'Callback triggered');50 assert.deepEqual(fakeData1, hash.d1, 'Shoulbe be passed to the handler');51 assert.deepEqual(fakeData2, hash.d2, 'Shoulbe be passed to the handler');52 };53 Events.on(el, ['event1', 'event2'], listener);54 Events.trigger(el, 'event1', { d1: fakeData1, d2: fakeData2});55 Events.trigger(el, 'event2', { d1: fakeData1, d2: fakeData2});56 Events.off(el, ['event1', 'event2'], listener);57});58QUnit.test('should remove all listeners of a type', function(assert) {59 const el = document.createElement('div');60 let clicks = 0;61 const listener = function() {62 clicks++;63 };64 const listener2 = function() {65 clicks++;66 };67 Events.on(el, 'click', listener);68 Events.on(el, 'click', listener2);69 // 2 clicks70 Events.trigger(el, 'click');71 assert.ok(clicks === 2, 'both click listeners fired');72 Events.off(el, 'click');73 // No click should happen.74 Events.trigger(el, 'click');75 assert.ok(clicks === 2, 'no click listeners fired');76});77QUnit.test('should remove all listeners of an array of types', function(assert) {78 const el = document.createElement('div');79 let calls = 0;80 const listener = function() {81 calls++;82 };83 const listener2 = function() {84 calls++;85 };86 Events.on(el, ['click', 'event1'], listener);87 Events.on(el, ['click', 'event1'], listener2);88 // 2 calls89 Events.trigger(el, 'click');90 // 2 calls91 Events.trigger(el, 'event1');92 assert.ok(calls === 4, 'both click listeners fired');93 Events.off(el, ['click', 'event1']);94 // No click should happen.95 Events.trigger(el, 'click');96 // No event1 should happen.97 Events.trigger(el, 'event1');98 assert.ok(calls === 4, 'no event listeners fired');99});100QUnit.test('should remove all listeners from an element', function(assert) {101 assert.expect(2);102 const el = document.createElement('div');103 const listener = function() {104 assert.ok(true, 'Fake1 Triggered');105 };106 const listener2 = function() {107 assert.ok(true, 'Fake2 Triggered');108 };109 Events.on(el, 'fake1', listener);110 Events.on(el, 'fake2', listener2);111 Events.trigger(el, 'fake1');112 Events.trigger(el, 'fake2');113 Events.off(el);114 // No listener should happen.115 Events.trigger(el, 'fake1');116 Events.trigger(el, 'fake2');117 Events.off(el, 'fake1', listener);118 Events.off(el, 'fake2', listener2);119});120QUnit.test('should listen only once', function(assert) {121 assert.expect(1);122 const el = document.createElement('div');123 const listener = function() {124 assert.ok(true, 'Click Triggered');125 };126 Events.one(el, 'click', listener);127 // 1 click128 Events.trigger(el, 'click');129 // No click should happen.130 Events.trigger(el, 'click');131});132QUnit.test('should listen only once in multiple events from a single call', function(assert) {133 assert.expect(3);134 const el = document.createElement('div');135 const listener = function() {136 assert.ok(true, 'Callback Triggered');137 };138 Events.one(el, ['click', 'event1', 'event2'], listener);139 // 1 click140 Events.trigger(el, 'click');141 // No click should happen.142 Events.trigger(el, 'click');143 // event1 must be handled.144 Events.trigger(el, 'event1');145 // No event1 should be handled.146 Events.trigger(el, 'event1');147 // event2 must be handled.148 Events.trigger(el, 'event2');149 // No event2 should be handled.150 Events.trigger(el, 'event2');151});152QUnit.test('should stop immediate propagtion', function(assert) {153 assert.expect(1);154 const el = document.createElement('div');155 Events.on(el, 'test', function(e) {156 assert.ok(true, 'First listener fired');157 e.stopImmediatePropagation();158 });159 Events.on(el, 'test', function(e) {160 assert.ok(false, 'Second listener fired');161 });162 Events.trigger(el, 'test');163 Events.off(el, 'test');164});165QUnit.test('should bubble up DOM unless bubbles == false', function(assert) {166 assert.expect(3);167 const outer = document.createElement('div');168 const inner = outer.appendChild(document.createElement('div'));169 // Verify that if bubbles === true, event bubbles up dom.170 Events.on(inner, 'bubbles', function(e) {171 assert.ok(true, 'Inner listener fired');172 });173 Events.on(outer, 'bubbles', function(e) {174 assert.ok(true, 'Outer listener fired');175 });176 Events.trigger(inner, { type: 'bubbles', target: inner, bubbles: true });177 // Only change 'bubbles' to false, and verify only inner handler is called.178 Events.on(inner, 'nobub', function(e) {179 assert.ok(true, 'Inner listener fired');180 });181 Events.on(outer, 'nobub', function(e) {182 assert.ok(false, 'Outer listener fired');183 });184 Events.trigger(inner, { type: 'nobub', target: inner, bubbles: false });185 Events.off(inner, 'bubbles');186 Events.off(outer, 'bubbles');187 Events.off(inner, 'nobub');188 Events.off(outer, 'nobub');189});190QUnit.test('should have a defaultPrevented property on an event that was prevent from doing default action', function(assert) {191 assert.expect(2);192 const el = document.createElement('div');193 Events.on(el, 'test', function(e) {194 assert.ok(true, 'First listener fired');195 e.preventDefault();196 });197 Events.on(el, 'test', function(e) {198 assert.ok(e.defaultPrevented, 'Should have `defaultPrevented` to signify preventDefault being called');199 });200 Events.trigger(el, 'test');201 Events.off(el, 'test');202});203QUnit.test('should have relatedTarget correctly set on the event', function(assert) {204 assert.expect(2);205 const el1 = document.createElement('div');206 const el2 = document.createElement('div');207 const relatedEl = document.createElement('div');208 Events.on(el1, 'click', function(e) {209 assert.equal(e.relatedTarget, relatedEl, 'relatedTarget is set for all browsers when related element is set on the event');210 });211 Events.trigger(el1, { type: 'click', relatedTarget: relatedEl });212 Events.on(el2, 'click', function(e) {213 assert.equal(e.relatedTarget, null, 'relatedTarget is null when none is provided');214 });215 Events.trigger(el2, { type: 'click', relatedTarget: undefined });216 Events.off(el1, 'click');217 Events.off(el2, 'click');218});219QUnit.test('should execute remaining handlers after an exception in an event handler', function(assert) {220 assert.expect(1);221 const oldLogError = log.error;222 log.error = function() {};223 const el = document.createElement('div');224 const listener1 = function() {225 throw new Error('GURU MEDITATION ERROR');226 };227 const listener2 = function() {228 assert.ok(true, 'Click Triggered');229 };230 Events.on(el, 'click', listener1);231 Events.on(el, 'click', listener2);232 // 1 click233 Events.trigger(el, 'click');234 log.error = oldLogError;235 Events.off(el, 'click');236});237QUnit.test('trigger with an object should set the correct target property', function(assert) {238 const el = document.createElement('div');239 Events.on(el, 'click', function(e) {240 assert.equal(e.target, el, 'the event object target should be our element');241 });242 Events.trigger(el, { type: 'click'});243 Events.off(el, 'click');244});245QUnit.test('retrigger with a string should use the new element as target', function(assert) {246 const el1 = document.createElement('div');247 const el2 = document.createElement('div');248 Events.on(el2, 'click', function(e) {249 assert.equal(e.target, el2, 'the event object target should be the new element');250 });251 Events.on(el1, 'click', function(e) {252 Events.trigger(el2, 'click');253 });254 Events.trigger(el1, 'click');255 Events.trigger(el1, {type: 'click'});256 Events.off(el1, 'click');257 Events.off(el2, 'click');258});259QUnit.test('retrigger with an object should use the old element as target', function(assert) {260 const el1 = document.createElement('div');261 const el2 = document.createElement('div');262 Events.on(el2, 'click', function(e) {263 assert.equal(e.target, el1, 'the event object target should be the old element');264 });265 Events.on(el1, 'click', function(e) {266 Events.trigger(el2, e);267 });268 Events.trigger(el1, 'click');269 Events.trigger(el1, {type: 'click'});270 Events.off(el1, 'click');271 Events.off(el2, 'click');...

Full Screen

Full Screen

delegate-test.js

Source:delegate-test.js Github

copy

Full Screen

1Ink.requireModules(['Ink.Dom.Event_1', 'Ink.Dom.Element_1', 'Ink.Dom.Selector_1', 'Ink.Dom.Browser_1'], function (InkEvent, InkElement, Selector, Browser) {2 if (!document.querySelectorAll) {3 /*4 It's impossible to get QUnit to run one test at a time, and these tests alter and depend on InkEvent state (setSelectorEngine).5 When querySelectorAll exists, these tests pass, because QUnit's insanity can't affect them.6 */7 return;8 }9 module('delegate', {10 setup: function(spy, target){11 globalSetUp.call(this);12 this.verifySimpleDelegateSpy = function (spy, target) {13 equal(spy.callCount, 2, 'delegated on selector')14 strictEqual(spy.thisValues[0], target, 'context (this) was set to delegated element')15 strictEqual(spy.thisValues[1], target, 'context (this) was set to delegated element')16 ok(spy.firstCall.args[0], 'got an event object argument')17 ok(spy.secondCall && spy.secondCall.args[0], 'got an event object argument')18 strictEqual(spy.firstCall.args[0].currentTarget, target, 'delegated event has currentTarget property correctly set')19 strictEqual(spy.secondCall && spy.secondCall.args[0].currentTarget, target, 'delegated event has currentTarget property correctly set')20 }21 },22 teardown: function(){23 globalTearDown.call(this);24 InkEvent.setSelectorEngine();25 }26 });27 asyncTest('should be able to delegate on selectors', function(){28 var self = this;29 this.runTest = function(done, regFn){30 var el1 = self.byId('foo');31 var el2 = self.byId('bar');32 var el3 = self.byId('baz');33 var el4 = self.byId('bang');34 var trigger = self.trigger();35 var spy = self.spy();36 regFn(el1, trigger.wrap(spy));37 Syn.click(el2);38 Syn.click(el3);39 Syn.click(el4);40 trigger.after(function () {41 self.verifySimpleDelegateSpy(spy, el2);42 start();43 })44 }45 this.runTest(start, function(el1, wrappedSpy){46 InkEvent.on(el1, 'click', '.bar', wrappedSpy);47 });48 });49 asyncTest('should be able to delegate multiple events', function(){50 var self = this;51 this.runTest = function(done, regFn){52 var el1 = self.byId('foo');53 var el2 = self.byId('bar');54 var el3 = self.byId('baz');55 var trigger = self.trigger();56 var spy = self.spy();57 regFn(el1, trigger.wrap(spy));58 Syn.click(el2);59 Syn.click(el3);60 trigger.after(function () {61 self.verifySimpleDelegateSpy(spy, el2);62 start();63 }, 50)64 }65 this.runTest(start, function(el1, wrappedSpy){66 InkEvent.on(el1, 'mouseup mousedown', '.bar', wrappedSpy);67 });68 });69 asyncTest('should be able to delegate on array', function(){70 var self = this;71 this.runTest = function(done, regFn){72 var el1 = self.byId('foo');73 var el2 = self.byId('bar');74 var el3 = self.byId('baz');75 var el4 = self.byId('bang');76 var trigger = self.trigger();77 var spy = self.spy();78 regFn(el1, el2, trigger.wrap(spy));79 Syn.click(el2);80 Syn.click(el3);81 Syn.click(el4);82 trigger.after(function () {83 self.verifySimpleDelegateSpy(spy, el2);84 start();85 });86 }87 this.runTest(start, function(el1, el2, wrappedSpy){88 InkEvent.on(el1, 'click', [el2], wrappedSpy);89 });90 });91 asyncTest('should be able to remove delegated handler', function(){92 var self = this;93 this.runTest = function(done, regFn){94 var el1 = self.byId('foo');95 var el2 = self.byId('bar');96 var calls = 0;97 var trigger = self.trigger();98 var fn = function() {99 calls++;100 InkEvent.remove(el1, 'click', trigger.wrapped(fn));101 };102 regFn(el1, trigger.wrap(fn));103 Syn.click(el2);104 Syn.click(el2);105 trigger.after(function () {106 equal(calls, 1, 'delegated event triggered once');107 start();108 })109 }110 this.runTest(start, function(el1, wrappedSpy){111 InkEvent.on(el1, 'click', '.bar', wrappedSpy);112 });113 });114 asyncTest('should use qSA if available', function(){115 var self = this;116 this.runTest = function(done, regFn){117 if(!features.qSA){118 ok(true, 'qSA not available');119 return start();120 }121 var el1 = self.byId('foo');122 var el2 = self.byId('bar');123 var el3 = self.byId('baz');124 var el4 = self.byId('bang');125 var trigger = self.trigger();126 var spy = self.spy();127 InkEvent.setSelectorEngine();128 regFn(el1, trigger.wrap(spy));129 Syn.click(el2);130 Syn.click(el3);131 Syn.click(el4);132 trigger.after(function () {133 self.verifySimpleDelegateSpy(spy, el2);134 start();135 })136 }137 this.runTest(start, function(el1, wrappedSpy){138 InkEvent.on(el1, 'click', '.bar', wrappedSpy);139 });140 });141 asyncTest('should throw error when no qSA available and no selector engine set', function(){142 var self = this;143 this.runTest = function(done, regFn){144 if(features.qSA){145 ok(true, 'qSA available in this browser, skipping test');146 return start();147 }148 var el1 = self.byId('foo');149 var el2 = self.byId('bar');150 var spy = self.spy();151 InkEvent.setSelectorEngine();152 regFn(el1, spy);153 window.onerror = function (e){154 ok(e.toString(), /Bean/, 'threw Error on delegated event trigger without selector engine or qSA');155 window.onerror = null;156 };157 Syn.click(el2);158 defer(function(){159 equal(spy.callCount, 0, 'don\'t fire delegated event without selector engine or qSA');160 start();161 });162 }163 this.runTest(start, function(el1, wrappedSpy){164 InkEvent.on(el1, 'click', '.bar', wrappedSpy);165 });166 });167 asyncTest('should be able to set a default selector engine', function(){168 var self = this;169 this.runTest = function(done, regFn){170 var el1 = self.byId('foo');171 var el2 = self.byId('bar');172 var el3 = self.byId('baz');173 var el4 = self.byId('bang');174 var selector = 'SELECTOR? WE DON\'T NEED NO STINKIN\' SELECTOR!';175 var trigger = self.trigger();176 var stub = self.stub();177 var spy = self.spy();178 stub.returns([el2]);179 InkEvent.setSelectorEngine(stub);180 regFn(el1, selector, trigger.wrap(spy));181 Syn.click(el2);182 Syn.click(el3);183 Syn.click(el4);184 trigger.after(function () {185 equal(stub.callCount, 6, 'selector engine called');186 strictEqual(stub.firstCall.args[0], selector, 'selector engine called with selector argument');187 strictEqual(stub.firstCall.args[1], el1, 'selector engine called with selector argument');188 self.verifySimpleDelegateSpy(spy, el2);189 InkEvent.setSelectorEngine(null);190 start();191 })192 }193 this.runTest(start, function(el1, selector, wrappedSpy){194 InkEvent.on(el1, 'click', selector, wrappedSpy);195 });196 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const wdio = require("webdriverio");2const opts = {3 capabilities: {4 }5};6async function main() {7 const client = await wdio.remote(opts);8 const el1 = await client.$("~MyButton");9 await el1.click();10 await client.deleteSession();11}12main();13[HTTP] {"using":"accessibility id","value":"MyButton"}14[debug] [MJSONWP] Calling AppiumDriver.findElement() with args: ["accessibility id","MyButton","7d1f1a8b-1d9e-4a2a-9f6f-1a5f0f2c7e2d"]15[debug] [JSONWP Proxy] Got response with status 200: {"value":{"ELEMENT":"F8F0C9A2-0D2A-4C3A-8F3C-3F3F4A4B4B1D","type":"XCUIElementTypeButton","label":"MyButton"},"sessionId":"7D1F1A8B-1D9E-4A2A-9F6F-1A5F0F2C7E2D","status":0}16[debug] [MJSONWP] Responding to client with driver.findElement() result: {"ELEMENT":"F8F0C9A2-0D2A-4C3A-8F3C-3

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Test', () => {2 it('should do something', async () => {3 await browser.pause(1000);4 await browser.elementClick('id=com.google.android.googlequicksearchbox:id/search_box_text');5 await browser.pause(1000);6 });7});8describe('Test', () => {9 it('should do something', async () => {10 await browser.pause(1000);11 await browser.elementClick('id=com.google.android.googlequicksearchbox:id/search_box_text');12 await browser.pause(1000);13 });14});15describe('Test', () => {16 it('should do something', async () => {17 await browser.pause(1000);18 await browser.elementClick('id=com.google.android.googlequicksearchbox:id/search_box_text');19 await browser.pause(1000);20 });21});22describe('Test', () => {23 it('should do something', async () => {24 await browser.pause(1000);25 await browser.elementClick('id=com.google.android.googlequicksearchbox:id/search_box_text');26 await browser.pause(1000);27 });28});29describe('Test', () => {30 it('should do something', async () => {31 await browser.pause(1000);32 await browser.elementClick('id=com.google.android.googlequicksearchbox:id/search_box_text');33 await browser.pause(1000);34 });35});36describe('Test', () => {37 it('should do something', async () => {38 await browser.pause(1000);39 await browser.elementClick('id=com.google.android.google

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Appium Xcuitest Driver automation tests on LambdaTest cloud grid

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

Sign up Free
_

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful