nightwatch.js

Global variable in nightwatch. Issue in for loop for node.js

眉间皱痕 提交于 2019-12-13 05:08:50
问题 I am currently working with node + nightwatch + selenium for automation. I came across a scenario: I have defined an array as Global array in nightwatch: Dev.js 'checkforLink':{ link1:"Some Xpath 1", link1:"Some Xpath 2", link1:"Some Xpath 3", link1:"Some Xpath 4" }, In my custom js script in custom-commands, I am doing a for loop to fetch this links from global variable: exports.command = function(callback) { browser = this; var data = browser.globals; console.log("Before all loop"); for(var

Phantomjs browser incorrectly computing css calc() function in Nightwatch tests

我是研究僧i 提交于 2019-12-13 03:00:01
问题 I am building Nightwatch tests (uses Phantomjs) for functioning front ends, and one of my tasks is to make sure banner images' heights are dynamic and their heights are being calculated correctly per the screen size. I have some page elements that look something like this: //html <div class="bannerImg"></div> //css .bannerImg { background-image: url('someImgUrl'); height: calc(100vh - 200); //some calculation here min-height: 600px; //some minimum height } For example, a viewport of 1080

Nightwatch(PageObject) access elements from different page object

雨燕双飞 提交于 2019-12-12 18:20:31
问题 Is there a way to access elements defined in one page object file from another page object file? Example: If we need to access '@usernameInput' from LoginPage.ts file, do we need to duplicate it from HomePage.ts ? Is there any other way? HomePage.ts const page: PageObject = { url: ..., commands: [ enterUsername: (query: string) => { return this .waitForElementVisible('@usernameInput') }], elements: { usernameInput: { locateStrategy: 'xpath', selector: '//input[@name="Username"]', } };

How to create condition “if element not exist - do smth” by using Nightwatch?

五迷三道 提交于 2019-12-12 05:24:20
问题 I have a list of users, presented by table, and I need to search for td element with appropriate value - and if element not exist on current page - click on link to go on another page. I have no ideas how to do this but I used xpath selector to find element with some value. Each user presented by "tr" element and contains "td" elements inside: <tr> <td class="break-all">acceptance</td> <td>client</td> <td class="break-all"></td> </tr> So, I need to find td element with value = "acceptance",

Nightwatch execute command within for loop runs out of order

泄露秘密 提交于 2019-12-11 20:14:05
问题 I'm pretty new to unit testing, but I've been trying to create a script with Nightwatch that goes through the body content of a page, clicks every link and reports back whether it's broken. I'm trying to make a for loop that iterates through each tag in the body content, counts the number of 'a' tags contained within and then clicks on each of them, but whenever I use a browser.execute command within a for loop, the script executes out of order. Here's my code. I've thrown in a couple of

Failing a Jenkins job when nightwatch test assertion fails in Browserstack

﹥>﹥吖頭↗ 提交于 2019-12-11 18:33:43
问题 I have a Jenkins job that runs Selenium tests on Browserstack via the Nightwatch.js framework. We have an entire suite of tests that nightwatch runs in separate processes, and we need a way to get the pass/fail value back to Jenkins after all tests have run. I have been trying to use the Nightwatch hook teardown to run a piece of code at the end of each module with if(this.results.failed) { take action } , but I can't figure out what action I need to take in order to make the failure

Running Nightwatch test in Firefox fails when using Windows Task Scheduler

谁都会走 提交于 2019-12-11 17:58:46
问题 I want to run Nightwatch Test with Firefox in the background using Windows Task Scheduler. I am able to run the test manually. However, I got an error when I run the task using Windows Task Scheduler. The selenium started successfully but there was a problem with the Firefox/Gecko Driver. The test is successful with IE and Chrome. I have read from this discussion: andreastt commented on 11 Sep 2017 geckodriver does not support running as Windows service. How do I fix this? Is there any

Make a 'common' login.js include; with nightwatch.js tests

喜你入骨 提交于 2019-12-11 15:19:46
问题 When writing tests for my web app; I have to first simulate login before the rest of my tests can run and see inner pages. Right now I'm working on modulating the code, so that way I can just make an 'include' for the common function; such as my login. But as soon as I move the below code in a separate file, and call the include via require - it no longer runs as expected. ie. the below logs in and allows my other functions, if, included in the same file. above my other inner screen functions

Proper way to limit wait time on selenium element search

隐身守侯 提交于 2019-12-11 12:41:20
问题 My nightwatch/selenium test code looks for elements in the page that may not exist using code such as browser.elementIdElement(ELEMENT,'class name', 'myclass', function(r) { if (r.status == 0) console.log('found match') else console.log('did not find match') }) If the element is found, the callback is invoked quickly (< 50ms), but if no element matches, the callback takes much longer (>1000ms). I have to do this hundreds of times and there are only a few elements that match the search

clicks do not work in nightwatch.js

帅比萌擦擦* 提交于 2019-12-11 11:41:04
问题 Sometimes clicks do not work in Firefox or Chrome when I am using nightwatch. I have the following code browser .waitForElementVisible('.example') .click('.example') .waitForElementVisible('body') The problem is the click event doesn't fire. Does anyone know why clicks sometimes do not work when using nightwatch.js and what you should do to accomodate this? 回答1: I guess, you should specify the time period in the function waitForElementVisible('body', 1000 ). Update the code with this and see