nightwatch.js

Custom useragent in nightwatch

﹥>﹥吖頭↗ 提交于 2019-12-11 11:31:43
问题 Is there a way to set a custom useragent for just one test in nightwatch? I want to test a page using both mobile and non-mobile useragents to ensure the proper experience is shown. I tried setting it as a cookie but it didn't work: browser .setCookie({ name : "User_Agent", value : "iphone", }) .url('...') // etc 回答1: Your test suite must be independent of the browser targeted. You should set the user agent directly in the NightWatch configuration json file : "test_settings" : { "default" : {

Nightwatch.js: why do I get Unable to create new service: GeckoDriverService?

瘦欲@ 提交于 2019-12-11 09:47:49
问题 I am trying to setup the latest nightwatch.js for the first time. This is my nightwatch.json: { "src_folders" : ["tests"], "output_folder" : "reports", "custom_commands_path" : "", "custom_assertions_path" : "", "page_objects_path" : "", "globals_path" : "", "selenium" : { "start_process" : true, "server_path" : "selenium-server-standalone-3.8.1.jar", "log_path" : "", "port" : 4444, "cli_args" : { "webdriver.chrome.driver" : "", "webdriver.gecko.driver" : "", "webdriver.edge.driver" : "" } },

wait for element present without error

好久不见. 提交于 2019-12-11 06:17:17
问题 is there a way to call waitForElementPresent in nightwatch without erroring out if the element is not there? Right now, if you pass in false as the third parameter, you still see an error. Ideally, I would like a function that waits for an element, and returns if it didn't find the element. 回答1: you can do it : Browser.waitForElementPresent('@element',3000,false, function(result){ If(result.value === true){ // test if element present }else{ // test if element not present } }) Since the day

Error running Selenium automatically from Nightwatch.js with Firefox

可紊 提交于 2019-12-11 05:05:20
问题 I want to start Selenium Server automatically when I run a nightwatch.js test case. I changed the selenium settings on nightwatch.json to: "selenium" : { "start_process" : true, "server_path" : "./selenium/selenium391.jar", "log_path" : "C:/Projects/reports", "host" : "127.0.0.1", "port" : 4444, "cli_args" : { "webdriver.chrome.driver" : "./selenium/chromedriver.exe", "webdriver.ie.driver" : "./selenium/IEDriverServer.exe", "webdriver.firefox.profile" : "./selenium/geckodriver.exe" } }, This

NIghtwatch.js error: "Cannot read propery 'equal' of undefined

百般思念 提交于 2019-12-11 03:41:13
问题 I'm trying to run a simple Nightwatch.js test to login, tell the form to remember the login, and then test the cookie to see if a boolean value exists. Every time I try to run the test, I get an Error: "Cannot read propery 'equal' of undefined" which is tied to the callback function for client.getCookie() . Can anyone help me to understand how to fix this error? Here is my code: module.exports = { 'Test "Keep me logged in." ' : function (client) { client .windowMaximize() .url('www.mysite.com

Xpath in Nightwatch.js

依然范特西╮ 提交于 2019-12-11 01:37:51
问题 I have this structure <div class ="wg-block"> ... <h4 class ="number" > "Text" I have to make sure that the element h4 with text "text" is in div. I try this: .useXpath() .waitForElementVisible('/div[contains(@class, "wg-block")]/h4[text()="Text"]',1000) but have an error. How can I correctly be sure in visibility of this element? 回答1: Try to replace '/div[contains(@class, "wg-block")]/h4[text()="Text"]' with '//div[@class = "wg-block"]//h4[normalize-space(text())="Text"]' Note that starting

clicking dynamic text using xpath and nightwatch.js

两盒软妹~` 提交于 2019-12-11 00:17:20
问题 I wish to click on an element with dynamic text in my app. Generally to click on an element with text I do the following: .useXpath().click("//*[contains(text(), 'some text')]") For my tests which have a dynamic name I try the following: .useXpath().click("//*[contains(text(), "${name}")]") where name is a variable which contains the name of the newly created account. However when I try to run my tests I get the following: .useXpath().click("//*[contains(text(), "${name}")]") ^^^^^^^^^^^^^^^^

What are some best practices for structuring e2e tests?

房东的猫 提交于 2019-12-10 21:43:40
问题 I'm a bit confused as to the best way to structure end to end tests. Most tests tests that I write depend on other tests. i.e User needs to log in User needs to create Foo User can now create Bar Bar needs to exist, in order to edit it obviously. How would you structure your tests to take this into account? 回答1: I would personally make use of the PageObject pattern, this will allow reliability and make the code more maintainable in these situations. Once you have that in place you can then

launch tests in Chrome with Nightwatchjs on Mac OS: “Connection refused! Is selenium server started?”

安稳与你 提交于 2019-12-10 17:36:50
问题 I am able to run my tests with Firefox using the following command: nightwatch -t tests/test4.js My nightwatchjs.json config file: { "src_folders" : ["tests"], "output_folder" : "reports", "custom_commands_path" : "", "custom_assertions_path" : "", "globals_path" : "", "selenium" : { "start_process" : true, "server_path" : "selenium-server-standalone-2.44.0.jar", "log_path" : "", "host" : "127.0.0.1", "port" : 4444, "cli_args" : { "webdriver.chrome.driver" : "drivers/chromedriver" } }, "test

chromedriver works but “phantomjs unable to locate item using css selector”

穿精又带淫゛_ 提交于 2019-12-10 17:03:24
问题 I'm designing some end to end testing for my job, and I've got it up and running using nightwatch.js through chromedriver. However, we're looking to have this run on our servers, and so I wanted to be able to run it using phantomjs. Although the test performs without incident using chromedriver, Phantomjs yields the following error "phantomjs unable to locate item using css selector" Any ideas? I've scoured the internet for a solution, to no avail. 回答1: First, check decates ' comment here: