How to use waitAndGetActionableElement method in taiko

Best JavaScript code snippet using taiko

pageActionChecks.test.js

Source:pageActionChecks.test.js Github

copy

Full Screen

...70 });71 pageActionChecks.__set__('findElements', () => [72 { isVisible: () => true, isDisabled: () => false },73 ]);74 await pageActionChecks.waitAndGetActionableElement('Something');75 expect(actualCheck).to.deep.equal(defaultChecks);76 });77 it('should call checkActionable with given checks concatinated with default checks', async () => {78 const expectedChecks = [79 pageActionChecks.checksMap.visible,80 pageActionChecks.checksMap.connected,81 pageActionChecks.checksMap.disabled,82 pageActionChecks.checksMap.stable,83 pageActionChecks.checksMap.writable,84 ];85 let actualCheck;86 pageActionChecks.__set__('checkIfActionable', (elem, checks) => {87 actualCheck = checks;88 return { actionable: true, error: null };89 });90 pageActionChecks.__set__('findElements', () => [91 { isVisible: () => true, isDisabled: () => false },92 ]);93 await pageActionChecks.waitAndGetActionableElement('Something', false, [94 pageActionChecks.checksMap.writable,95 ]);96 expect(actualCheck).to.have.members(expectedChecks);97 });98 it('should return first element that is actionable', async () => {99 pageActionChecks.__set__('runtimeHandler', {100 runtimeCallFunctionOn: (a, b, c) => {101 {102 return { result: { value: true } };103 }104 },105 });106 pageActionChecks.__set__('findElements', () => [107 {108 name: 'notActionable',109 get: () => 1,110 isVisible: () => true,111 isDisabled: () => true,112 isConnected: () => true,113 },114 {115 name: 'Actionable',116 get: () => 2,117 isVisible: () => true,118 isDisabled: () => false,119 isConnected: () => true,120 },121 ]);122 const result = await pageActionChecks.waitAndGetActionableElement('Something');123 expect(result.name).to.equal('Actionable');124 });125 it('should throw error when no actionable element is found in default number of element to check', async () => {126 pageActionChecks.__set__('findElements', () => [127 { name: 'notActionable', isVisible: () => true, isDisabled: () => true },128 { name: 'notActionable', isVisible: () => true, isDisabled: () => true },129 { name: 'notActionable', isVisible: () => true, isDisabled: () => false },130 ]);131 await expect(132 pageActionChecks.waitAndGetActionableElement('Something'),133 ).to.be.eventually.rejectedWith(134 'Found too many matches. Please use a selector that is more specific',135 );136 });137 it('should throw error when no actionable element is found and force false', async () => {138 pageActionChecks.__set__('findElements', () => [139 { name: 'notActionable', isVisible: () => true, isDisabled: () => true },140 { name: 'notActionable', isVisible: () => true, isDisabled: () => true },141 ]);142 await expect(143 pageActionChecks.waitAndGetActionableElement('Something'),144 ).to.be.eventually.rejectedWith('Element matching text "Something" is disabled');145 });146 it('should retrun the first element if no match is found and force true', async () => {147 pageActionChecks.__set__('findElements', () => [148 { name: 'notActionable1', isVisible: () => true, isDisabled: () => true },149 { name: 'notActionable2', isVisible: () => true, isDisabled: () => true },150 ]);151 const result = await pageActionChecks.waitAndGetActionableElement('Something', true);152 expect(result.name).to.equal('notActionable1');153 });154 });...

Full Screen

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 taiko 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