Reputation: 36161
I have a project in Django, with some pages using React to enhance user experience. I want to create integration tests to ensure there is no regression in those pages over time. After some struggling, I chose to test nightwatch.js
.
I have my webserver dedicated for testing running on localhost:8500
and I want that all queries done by nightwatch.js goes on this server. I configured the test tools like this :
...
"test_settings" : {
"default" : {
"launch_url" : "http://localhost:8500/",
...
The problem is I don't know how to use this setting. When I am using the init()
method, it looks like the test get stucked on the homepage... For example, with this test:
module.exports = {
'Test account login in /admin': function (browser) {
browser.init().url('/admin/')
.waitForElementVisible('body', 1000)
.setValue('#id_username', 'username')
... + click, wait, check results
.end();
}
};
... fails, and I can see it is because the browser was still on the homepage (some assert in the code reveals elements from my homepage).
What's the problem here? How can I make the browser be initiliazed on a particular URL ?
Upvotes: 0
Views: 3436
Reputation: 36161
It looks like the .url()
method takes only absolute URL in parameter. You should navigate on your application either by clicking on links or submitting absolute URL through that function...
It is possible to make something DRY, by using browser.launchUrl
:
browser.url(browser.launchUrl+'admin/')
I opened an issue on the nightwatchjs Github to suggest the possibility to use relative URL.
Upvotes: 5