You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am encountering an issue where the browser object is not accessible within the BeforeAll or Before hooks when using Nightwatch.js with Cucumber.
Suggested solution
Scenario:
In my test setup, I need to fetch the user agent from the browser and update it before starting the test execution. To achieve this, I intend to use the execute command to retrieve the user agent. However, since the browser object is not available in the BeforeAll or Before hooks, I am unable to perform this operation.
Steps to Reproduce:
Set up a Nightwatch.js project with Cucumber integration.
Try to access the browser object within a BeforeAll or Before hook.
Attempt to use the execute command to fetch the user agent.
Expected Behavior:
The browser object should be accessible within the BeforeAll or Before hooks, allowing the use of the execute command to retrieve and update the user agent before the test execution begins.
Actual Behavior:
The browser object is not available in the BeforeAll or Before hooks, preventing the execution of commands that require the browser object.
Example Code:
const { BeforeAll, Before } = require('cucumber');
BeforeAll(async function() {
// Attempt to access the browser object and execute a command
const userAgent = await browser.execute(function() {
return navigator.userAgent;
});
// Update the user agent or perform other necessary actions
console.log('User Agent:', userAgent);
});
Request:
It would be highly beneficial if the browser object could be made available in the BeforeAll or Before hooks when using Nightwatch.js with Cucumber. This would enable pre-test setup tasks such as fetching and updating the user agent or other necessary configurations.
Thank you for your attention to this issue. I look forward to any suggestions or potential fixes.
Description
I am encountering an issue where the browser object is not accessible within the BeforeAll or Before hooks when using Nightwatch.js with Cucumber.
Suggested solution
Scenario:
In my test setup, I need to fetch the user agent from the browser and update it before starting the test execution. To achieve this, I intend to use the execute command to retrieve the user agent. However, since the browser object is not available in the BeforeAll or Before hooks, I am unable to perform this operation.
Steps to Reproduce:
Set up a Nightwatch.js project with Cucumber integration.
Try to access the browser object within a BeforeAll or Before hook.
Attempt to use the execute command to fetch the user agent.
Expected Behavior:
The browser object should be accessible within the BeforeAll or Before hooks, allowing the use of the execute command to retrieve and update the user agent before the test execution begins.
Actual Behavior:
The browser object is not available in the BeforeAll or Before hooks, preventing the execution of commands that require the browser object.
Example Code:
const { BeforeAll, Before } = require('cucumber');
BeforeAll(async function() {
// Attempt to access the browser object and execute a command
const userAgent = await browser.execute(function() {
return navigator.userAgent;
});
// Update the user agent or perform other necessary actions
console.log('User Agent:', userAgent);
});
Request:
It would be highly beneficial if the browser object could be made available in the BeforeAll or Before hooks when using Nightwatch.js with Cucumber. This would enable pre-test setup tasks such as fetching and updating the user agent or other necessary configurations.
Thank you for your attention to this issue. I look forward to any suggestions or potential fixes.
Alternatives / Workarounds
No response
Additional Information
#3038
The text was updated successfully, but these errors were encountered: