nightwatch.js

Nightwatch Page Object persistence

删除回忆录丶 提交于 2019-12-23 02:39:24
问题 Using Nightwatch's Page Object capability, I have all the elements of a page defined as well as its URL. After navigating to the page (e.g., page.navigate()), the code waits for the one of the elements to be visible and then records the values of several elements before clicking on another element that leaves the page. I want to ensure that the page is no longer displayed by waiting for that same element to not be displayed, but that second wait always times out and I'm forced to look for an

Nightwatch: Better way than `.pause(1000)` to avoid brittle tests?

荒凉一梦 提交于 2019-12-22 03:25:15
问题 Is .pause(1000) really the best-practice there is to wait for form submission? I'm looking for a way to reliably submit a form without having to know details about the page appearing as a result of the form submission. The example from the home page uses .pause(1000) to wait for form submissions, and ironically doesn't work any longer, but this version with a modified css-selector version does: module.exports = { 'Demo test Google' : function (client) { client .url('http://www.google.com')

Nightwatch: Better way than `.pause(1000)` to avoid brittle tests?

﹥>﹥吖頭↗ 提交于 2019-12-22 03:25:13
问题 Is .pause(1000) really the best-practice there is to wait for form submission? I'm looking for a way to reliably submit a form without having to know details about the page appearing as a result of the form submission. The example from the home page uses .pause(1000) to wait for form submissions, and ironically doesn't work any longer, but this version with a modified css-selector version does: module.exports = { 'Demo test Google' : function (client) { client .url('http://www.google.com')

Mock backend in nightwatch.js tests

心已入冬 提交于 2019-12-21 21:53:45
问题 In my Vue.js app I'm using nightwatch to test my app. I have the following spec: module.exports = { 'wrong email or password': function (browser) { const devServer = browser.globals.devServerURL var nock = require('nock'); var couchdb = nock('http://localhost:3000/') .get('api/v1/login') .reply(401, { error: 'dupa' }); browser .url(devServer + '/login') .setValue('input[type=email]', 'email@example.com') .setValue('input[type=password]', 'password') .click('.login') .assert.containsText('#app

Nightwatch.js - Can't figure out how to pass a local variable into a URL parameter

拥有回忆 提交于 2019-12-20 04:57:08
问题 I have tried both options, but nothing seems to work: var webNum = browser.getText('selector'); var urlGo = 'https://gotourl.com/' + webNum; browser.url(urlGo); or var webNum = browser.getText('selector'); browser.url('https://gotourl.com/' + webNum); Any ideas? 回答1: .getText() is returning a WebElement JSON Object rather than string (the documentation on nightwatch api is misleading...) The text you want is the value of the WebElement JSON Object , and you can access it by using .value if

Nightwatch.js: window is undefined

空扰寡人 提交于 2019-12-19 19:59:10
问题 I'm trying to use Nightwatch to test a React application. I'm using React-Router with it. When running my test with Nightwatch window is undefined. React uses the following snippet to test if the DOM is available: var canUseDOM = !!( typeof window !== 'undefined' && window.document && window.document.createElement ); From React.js source: ExecutionEnvironment.js#L16 React-Router expects canUseDOM to be true, otherwise it throws an error. So my test fails because window is undefined when

Nightwatch Cannot Find/Click on Dropdown Option

假装没事ソ 提交于 2019-12-19 05:58:08
问题 I'm a backpacker and a programmer, trying to use the second skill to find openings in a full campsite. Rather than crawling fro scratch, I'm using the end-to-end testing framework nightwatch.js to navigate for me. I've hit a roadblock, because nightwatch is having difficulty finding a specific element using css selectors. Here are the elements and page: Here is my test code: Previous Attempts My test code will click on the selection box with #permitTypeId . It will see that #permitTypeId

Nightwatch Cannot Find/Click on Dropdown Option

筅森魡賤 提交于 2019-12-19 05:58:00
问题 I'm a backpacker and a programmer, trying to use the second skill to find openings in a full campsite. Rather than crawling fro scratch, I'm using the end-to-end testing framework nightwatch.js to navigate for me. I've hit a roadblock, because nightwatch is having difficulty finding a specific element using css selectors. Here are the elements and page: Here is my test code: Previous Attempts My test code will click on the selection box with #permitTypeId . It will see that #permitTypeId

How to run 'window' js command in nightwatch js

拟墨画扇 提交于 2019-12-14 01:26:47
问题 Please i have some tests that varies depending on my device. I have to determine whether my device is mobile or desktop before beginning of a test. I wanted to exploit the nightwatch before function and i added below in my globals.js var self = module.exports = { environment: undefined, beforeEach: function (done) { self.environment = browser.window.navigator.userAgent; console.log("Run against: " + self.environment); done(); }, }; and i my test module.exports = { tags: ['assetindex'], 'visit

Nightwatch. Click on element with text

六月ゝ 毕业季﹏ 提交于 2019-12-14 01:00:28
问题 I have a problem, can`t click on web element having some unique text. I have this structure: <div class="wg-wagon-type__item" data-reactid="10" <div class="wg-wagon-type__title" data-reactid="11">Text</div> I try this .click('.wg-wagon-type__title:contains("Text")') But I have an error ERROR: Unable to locate element: ".wg-wagon-type__item .wg-wagon-type__title:contain("Text")" using: css selector How can I correct click on this element? 回答1: Is there any reason why you can't simply target