How to launch specific chrome profile for Web automation using webdriverIO?
Requirement: My website is launched with the "Login with Google Option", so I want to launch it through Automation with already stored profile in chrome browser. So it will bypass the login and directly getting launched inside the App.
Tools: WebDriverIO web Automation with JavaScript
Framework: Mocha
login.spec.js file:
const { Options } = require('webdriverio/build/ChromeOptions');
const { remote } = require('webdriverio');
const options = new Options();
options.addArguments("user-data-dir=/Users/dhrumilsoni/Library/Application Support/Google/Chrome/");
options.addArguments("--profile-directory=Profile 2");
options.addArguments("--start-maximized");
describe('App Admin Portal', () => {
let browser;
before(async () => {
browser = await remote({
capabilities: {
browserName: 'chrome',
'goog:chromeOptions': {
args: options.args,
},
},
});
await new Promise(resolve => setTimeout(resolve, 5000));
});
beforeEach(async () => {
// Wait for the browser to load the URL before each test case
await browser.url('https://google.com');
});
afterEach(async () => {
await browser.deleteSession();
});
it.only('login title verification',async () => {
browser.pause(3000);
try {
const title = await browser.getTitle();
expect(title).toEqual("TL");
} catch (error) {
console.error(error);
}
});
});
But I'm getting error post running "npx wdio" command.
Error: Unable to load spec files quite likely because they rely on `browser` object that is not fully initialised.`browser` object has only `capabilities` and some flags like `isMobile`.