this.driver.switchTo is not a function on axe core module

32 Views Asked by At

I am trying to automate the accessibility testing on mobile native application. As part of it i am using the axe-core/webdriverjs module. Whenever i try to run the axe on app, i am getting the following error

TypeError: this.driver.switchTo is not a function
    at AxeBuilder.analyzePromise (C:\axewebdriverioappium\androidaxeauto\node_modules\@axe-core\webdriverjs\dist\index.js:426:23)
    at C:\axewebdriverioappium\androidaxeauto\node_modules\@axe-core\webdriverjs\dist\index.js:398:19
    at new Promise (<anonymous>)
    at AxeBuilder.analyze (C:\axewebdriverioappium\androidaxeauto\node_modules\@axe-core\webdriverjs\dist\index.js:397:12)
    at Context.<anonymous> (C:\axewebdriverioappium\androidaxeauto\test\specs\final.js:10:69)

code:

const AxeBuilder = require('@axe-core/webdriverjs');

describe('sample', () =>{
    it('axe test', async() =>{
       await driver.pause(5000);
       await driver.startActivity("io.appium.android.apis","io.appium.android.apis.app.AlertDialogSamples");
       await driver.pause(5000);
       const axeResults = await new AxeBuilder(driver).withTags(['wcag2a', 'wcag2aa']).analyze();

       console.log('Accessibility Violations: ', axeResults.violdations);
    });
});

Note: desired capabilities, port details etc are mentioned in wdio.conf.js file. So my app is running successfully on android studio. Whenever i use the analyze, i am getting the above error. I am expecting the violation results. Thanks in advance.

0

There are 0 best solutions below