I have tried using :
event.test.before
. The session is not created yet.
. But I don't have access to the current test object.
event.test.started(test)
. I have access to the current test object.
. But the session is already created and there is no use modifying the config now.
Is there any other way/event using which I can achieve this ?
Yes, it's known problem. We use manualStart option for that: http://codecept.io/helpers/WebDriverIO/#configuration
You will need to enable it, and then create a method that w
manualStart (optional, default: false) - do not start browser before a test, start it manually inside a helper with this.helpers["WebDriverIO"]._startBrowser()
Thanks @DavertMik !
Your solution worked for me 馃憤
I did the following:
"manualStart": trueevent.test.started,container.helpers().WebDriverIO._startBrowser();In case someone is looking for a custom hook example:
const event = require('codeceptjs').event;
const container = require('codeceptjs').container;
module.exports = function () {
event.dispatcher.on(event.test.started, function (test) {
let index = test.file.lastIndexOf("/"); //get name of testfile
let build = test.file.substr(index).replace('/', '').replace('_test.js', '');
container.helpers().WebDriverIO.config.desiredCapabilities['name'] = test.title;
container.helpers().WebDriverIO.config.desiredCapabilities['build'] = build;
container.helpers().WebDriverIO.config.desiredCapabilities['project'] = 'testception';
container.helpers().WebDriverIO._startBrowser();
});
}
Thanks @DavertMik !
Your solution worked for me 馃憤I did the following:
- In codecept.json >
"manualStart": true- In custom hook; listen on
event.test.started,- Access the test object & modify the config as per your requirement.
- Start session using >
container.helpers().WebDriverIO._startBrowser();
Hi Prashant, will you be able to share this custom hook. I am trying the same to set names for browserstack.
Most helpful comment
Thanks @DavertMik !
Your solution worked for me 馃憤
I did the following:
"manualStart": trueevent.test.started,container.helpers().WebDriverIO._startBrowser();