I'd like to load a page and perform some functions before the start of each of my tests.
Is this possible?
I've added this in my globals file, but it doesn't seem to work;
module.exports = {
beforeEach: function (browser, done) {
console.log('setting up the test...');
browser.url('https://www.******.co.uk');
browser.pause(10000);
done();
}
};
Am I doing something obviously wrong with this, as it doesn't seem to display the 'setting up the test' text or load the webpage before the test starts. Thanks.
Ok, so I now need to run code in my command script that references an entry in my globals file.
So far, my code looks like this in my command file;
var cmsDataNewsLetterSettings = require('../../config/commands/solr_query/globalSettings/newsletterSignUp');
var cmsNewsletterSettingsPage;
module.exports = {
before: function(done) {
var solrPrdCmsClient = this.globals.solrPrdCmsClient;
cmsDataNewsLetterSettings.newsletter_signup_prompt_settings(solrPrdCmsClient, function(err,cmsNewsletterSettings) {
if(err) {
console.log(err);
done(err);
} else {
cmsNewsletterSettingsPage = cmsNewsletterSettings;
done();
}
});
var numberOfPagesBeforePromptDisplayed = cmsNewsletterSettingsPage.i_NewsletterSignupPageViewThreshold;
console.log(numberOfPagesBeforePromptDisplayed);
}
};
However, I'm getting the error message;
command: "TypeError: Cannot read property 'solrPrdCmsClient' of undefined
Am I right in thinking that this error is caused by the command script not recognising the globals reference, or is the error elsewhere? Thanks.
Hi.
As part of a beforeEach hook, I have this in my globals.js file;
var launchUrl = 'https://www.parkers.co.uk/';
module.exports = {
beforeEach: function (browser, done) {
browser.testSetup(launchUrl);
done();
},
However, instead of the definitive https://www.parkers.co.uk
for the launchUrl
, I'd like to reference this in a similar way as my test cases, so that it can be used for each environment (dev, test, etc). For example, in my test cases this URL is defined in the form of browser.launch_url
, which it gets from my nightwatch.conf.js config file;
test_settings: {
default: {
launch_url: 'https://www.parkers.co.uk/'
},
Is it possible to reference this nightwatch.conf.js entry within the globals.js file?
Any help would be greatly appreciated.
/all Hello everyone! We have a new Discord server setup and we'll discontinue the Gitter soon. Please join us at
See you there!
Hi all. I'm trying to find a specific entry in an injected script, within a page, and I can't find a way to do this.
Below is the html;
<script>
var parkersConfig = {
adRefreshTestCandidate: 'B',
enableAdRequestLogging: false,
environment: 'prd',
debugMode: true,
cookieDomain: 'parkers.co.uk',
betaEscapeUrl: 'https://www.parkers.co.uk/',
apiUrl: '/api/',
assetsUrl: 'https://parkers-assets.bauersecure.com/',
dataLayer: {"adverts":{"topAdVisibleFor":4000,"dfpAdUnitName":"car-reviews"},"oneSignal":{"carClassifications":["Saloon"],"section":"car-reviews"},"page":{"author":"Mike Humble","id":"195394","overrideGaLocation":null,"galleryGaLocation":"/car-review/gallery/","templateName":"Templates.ReviewIntroduction","cmsLastUpdatedDate":"16/11/2021"},"vehicle":{"vehicleType":"cars","vehicleName":"BMW 3-Series Saloon 2005","makeId":869,"makeName":"BMW","rangeId":100353,"rangeName":"3-Series","modelId":1345,"modelName":"3-Series Saloon (05-11)","bodyStyle":"Saloon","condition":"Used","fuelType":"petrol,diesel","gearboxType":"NotSet"},"suppressThirdPartyJavascript":false,"wordCount":"NotSet","suppressionExperimentId":"NotSet","analyticsAccount":"UA-10756961-1","gtmTestTagCandidate":"true","classification":"Saloon"},
graph: null,
userHasAcceptedStoreAccessInfoOnDevice: false
};
var bauerDataLayer = [ parkersConfig.dataLayer ];
var webpackChunkManifest = {};
</script>
and I need to assert that the "templateName":"Templates.ReviewIntroduction", part of the injected script is correct.
Firstly, is this possible in Nightwatch (to assert part of an injected script), and if so how can it be done?
Any help would be greatly appreciated, as I'm well and truly stuck on this one. Thanks.
Waiting for //*[contains(text(),"Sign In")] to be visible
Error while running .isElementDisplayed() protocol action: The command 'GET /session/2A27DE92-D1C7-4F41-803E-B12241A33833/element/node-584DC41D-FBA9-4A24-B0AE-57265B99DEB7/displayed' was not found.
/displayed
was deprecated from safari, however I cannot find a workaround for it.
I'm trying to disable local storage for Chrome for a test. I figured out how to do this using an env in nightwatch.conf.js via --disable-local-storage
. But I'd rather just disable local storage for a single test.
I tried const result = await browser.chrome.setPermission('persistent-storage', 'denied')
, but that api seems to always return an error about "opaque origins".
Is there a way for me to disable local storage for a single test? Like manipulating browser.capabilities or something?