Closed GnrySgtSkitlz closed 7 years ago
So that answer to this is that I was attempting to use HTTPS and not HTTP, looks like either the selenium webdriver or chromedriver doesn't like using secure urls.
@GnrySgtSkitlz that's odd could it be that the HTTPS has an unrecognised certificate?
@nelsonic I will double check, but i don't think its the case. I have a feeling, an I can't remember where I have read it but there is a way to set the chrome arguments. One of the arguments was to do with secure connection...I'll have another look.
I have followed the read me instructions and thankyou as they're very clear. However I am finding that when trying to assert that my title equals Home Page I either get a test failed, expected Home Page but got "" or failed, expected Home Page but got "local host".
I think it's a configuration issue as the waitForElementVisible('title') fails but waitForElementPresent('title') succeeds
The chrome window pops up but shows a default page and an alert saying that a testing program is running chrome.
I'll add some code snippets shortly as I'm not at my PC ....Edit.... Test
var config = require('../nightwatch.conf.js');
module.exports = { // adapted from: https://git.io/vodU0
'Login Assert': function(browser) {
browser
.url('https://localhost:5100/Login')
.waitForElementPresent('title')
.waitForElementVisible('body')
//.assert.title('Home Page')
.saveScreenshot('LandingScreen.png');
browser.assert.containsText('title', "Home Page")
}
};
Config //require('env2')('.env'); // optionally store your Evironment Variables in .env const SCREENSHOT_PATH = "./screenshots/"; const BINPATH = './node_modules/nightwatch/bin/';
// we use a nightwatch.conf.js file so we can include comments and helper functions module.exports = { "src_folders": [ "Portal/UIAutomationTests/"// Where you are storing your Nightwatch e2e tests ], "output_folder": "Portal/UIAutomationTestReports", // reports (test outcome) output by nightwatch "selenium": { // downloaded by selenium-download module (see readme) "start_process": true, // tells nightwatch to start/stop the selenium process "server_path": "./node_modules/nightwatch/bin/selenium.jar", "host": "127.0.0.1", "port": 4444, // standard selenium port "cli_args": { // chromedriver is downloaded by selenium-download (see readme) "webdriver.chrome.driver" : "./node_modules/nightwatch/bin/chromedriver" } }, "test_settings": { "default": { "screenshots": { "enabled": true, // if you want to keep screenshots "path": SCREENSHOT_PATH // save screenshots here }, "globals": { "waitForConditionTimeout": 5000 // sometimes internet is slow so wait. }, "desiredCapabilities": { // use Chrome as the default browser for tests "browserName": "chrome" } }, "chrome": { "desiredCapabilities": { "browserName": "chrome", "javascriptEnabled": true // turn off to test progressive enhancement } } } } /**
selenium.jar
before trying to run our tests. */require('fs').stat(BINPATH + 'selenium.jar', function (err, stat) { // got it? if (err || !stat || stat.size < 1) { require('selenium-download').ensure(BINPATH, function(error) { if (error) throw new Error(error); // no point continuing so exit! console.log('✔ Selenium & Chromedriver downloaded to:', BINPATH); }); } });
function padLeft (count) { // theregister.co.uk/2016/03/23/npm_left_pad_chaos/ return count < 10 ? '0' + count : count.toString(); }
var FILECOUNT = 0; // "global" screenshot file count /**
module.exports.imgpath = imgpath; module.exports.SCREENSHOT_PATH = SCREENSHOT_PATH;
Results Running: Login Assert ✔ Element
Thanks in advance