Ok, so I know this is probably going to be something obvious and straightforward, but I just can't seem to get it to work.
Using the Nigthwatchjs perform command, I'm trying to re-use a variable from a step into the next step.
Below is a snippet of my code from my test script;
'2) Breadcrumbs': function (browser) {
browser.perform(function() {
var testMake = browser.globals.specsTestMake;
var testModel = browser.globals.specsTestModel;
var testRange = browser.globals.specsTestRange;
var testYear = browser.globals.specsTestYear;
browser.assert.containsText('nav.site-breadcrumbs', 'Home', testMake, testModel, testRange, testYear, 'specs');
console.log('test make from step 2 = ', testMake);
});
},
'3) Heading': function (browser) {
browser.perform(function(testMake, done) {
console.log('test make from step 3 = ', testMake);
done();
});
},
The console.log from the first step, '2) Breadcrumbs' is correctly displayed (for this test example) as BMW, as defined in the globals file.
I therefore thought that the console.log for the second step, '3) Heading' would also be correctly displayed as BMW.
However, this is not the case.
The second console.log displays what appears to be the entire page, settings, etc.
A small snippet is below;
✔ 2) Breadcrumbs (26ms)
test make from step 3 = { capabilities:
{ acceptInsecureCerts: true,
acceptSslCerts: true,
applicationCacheEnabled: false,
browserConnectionEnabled: false,
browserName: 'chrome',
chrome:
{ chromedriverVersion: '2.44.609545 (c2f88692e98ce7233d2df7c724465ecacfe74df5)',
userDataDir:
'/var/folders/6x/3kzp0zhd6vv0q_mfstkxd73m0000gr/T/.org.chromium.Chromium.iDQCXI' },
cssSelectorsEnabled: true,
databaseEnabled: false,
'goog:chromeOptions': { debuggerAddress: 'localhost:52102' },
handlesAlerts: true,
Any idea on what I'm doing wrong with my perform command?
Thanks
Related
I am unable to save a really simple connector in Ms Teams.
The connector I made is a part of an app, which only wraps this connector.
As Ms suggests, I use ngrok for my endpoints (config page). (I also tried it with a real URL too with the same result.)
I can successfully include the configuration page while adding the connector to my team, but when I press the save button, it almost always fails. (55 failed, once was OK. But why !!??!!)
The script I am using:
microsoftTeams.initialize();
microsoftTeams.settings.setSettings({
entityId: "sampleConfig24",
configName: "sampleConfig3",
contentUrl: "https://35e61433.ngrok.io/motivosity/msteams/config.xhtml"
});
microsoftTeams.settings.setValidityState(true);
microsoftTeams.settings.registerOnSaveHandler(function(saveEvent) {
console.log("saving....");
// microsoftTeams.settings.getSettings( function(s) {
// console.log(s);
// });
console.log("saved");
saveEvent.notifySuccess();
});
The browser console contains:
saving....
saved
{
"seq": 1587628706303,
"timestamp": 1587631139034,
"flightSettings": {
"Name": "ConnectorFrontEndSettings",
"AriaSDKToken": "d127f72a3abd41c9b9dd94faca947689-d58285e6-3a68-4cab-a458-37b9d9761d35-7033",
"SPAEnabled": true,
"ClassificationFilterEnabled": true,
"ClientRoutingEnabled": true,
"EnableYammerGroupOption": true,
"EnableFadeMessage": false,
"EnableDomainBasedOwaConnectorList": false,
"EnableDomainBasedTeamsConnectorList": false,
"DevPortalSPAEnabled": true,
"ShowHomeNavigationButtonOnConfigurationPage": false,
"DisableConnectToO365InlineDeleteFeedbackPage": true
},
"status": 500,
"clientType": "SkypeSpaces",
"connectorType": "b87e49ce-e49a-4b42-895d-faf86b21d74a",
"name": "handleMessageError"
}
This error message has no understandable part. Anyone knows what is this?
I also noticed, that when opening the connector page, I also see this message in the console (before pressing the save button:)
"AppsService: getInstalledAppForTeam - Invalid teamId and/or appId specified"
Aim:
I'd like to have two models(sets of data) passed to the custom control with a predefined search field, in which later on I can execute filtering.
I'm a newbie in OpenUi5, so I might be doing something wrong and stupid here. I've started with a simplified task of passing data from the frontend to my custom control and experiencing troubles.
Background of the simplified idea:
Create a custom control with an aggregation foo , the value to it will be provided from the view.
Also create another aggregation element _searchField which will be populated with the data provided from the view.
Fire the onSuggestTerm everytime user types in a _searchField.
Custom control code:
function (Control) {
var DropDownListInput = Control.extend('xx.control.DropDownListInput', {
metadata: {
defaultAggregation: 'foo',
aggregations: {
foo: { type: 'sap.m.SuggestionItem', multiple: true, singularName: 'suggestionItem' },
_searchField: { type: 'sap.m.SearchField', multiple: false, visibility: 'hidden' }
}
}
});
DropDownListInput.prototype.init = function () {
var that = this;
this.onSuggestTerm = function (event) {
var oSource = event.getSource();
var oBinding = that.getAggregation('foo');
oBinding.filter(new sap.ui.model.Filter({
filters: new sap.ui.model.Filter('DISEASE_TERM', sap.ui.model.FilterOperator.Contains, ' Other')
}));
oBinding.attachEventOnce('dataReceived', function () {
oSource.suggest();
});
};
this.setAggregation('_searchField', new sap.m.SearchField({
id: 'UNIQUEID1',
enableSuggestions: true,
suggestionItems: that.getAggregation('foo'),
suggest: that.onSuggestTerm
}));
};
return DropDownListInput;
}, /* bExport= */true);
I'm not providing Renderer function for control here, but it exists and this is the most important excerpt from it:
oRM.write('<div');
oRM.writeControlData(oControl);
oRM.write('>');
oRM.renderControl(oControl.getAggregation('_searchField'));
oRM.write('</div>');
Passing the data to this control from the xml frontend:
<xx:DropDownListInput
id="diseaseTermUNIQUE"
foo='{path: db2>/RC_DISEASE_TERM/}'>
<foo>
<SuggestionItem text="{db2>DISEASE_TERM}"
key="{db2>DISEASE_TERM}" />
</foo>
</xx:DropDownListInput>
The code fails to run with this error Cannot route to target: [object Object] -
and I have no idea what's wrong here..
The problem is that you forgot to provide single quotes in your path:
foo="{path: 'db2>/RC_DISEASE_TERM/'}"
I'm building some e2e test for my Vuejs application.
The framework I'm using is Nightwatch along with the http library Axios (and the relative plugin for mocking: Axios-mock-adapter) and my current process is to have a file that intercepts all the api, and a file that return the reponse object:
So for example, if I want to mock /api/sources:
mock.onGet(/my.url\/api\/sources/).reply(() =>
[200, ResponseObject.getSources],
);
And in the reponse object file I have:
const getSources = {
files: [
{
id: 'bogus',
fileName: 'bogus',
fileUrl: 'http://bogus.com/1',
size: 400,
uploadedTime: '2018-05-24 10:56:27',
sourceContact: 'boguscontact',
isFolder: false,
}, {
id: 'bogus2',
fileName: 'bogus 2',
fileUrl: 'http://bogus.com/2',
size: 500,
uploadedTime: '2018-05-24 10:56:27',
sourceContact: 'boguscontact',
isFolder: false,
}, {
id: 'bogus3',
fileName: 'bogus 3',
fileUrl: 'http://bogus.com/3',
size: 600,
uploadedTime: '2018-05-24 10:56:27',
sourceContact: 'boguscontact',
isFolder: false,
},
],
};
With this set up I have a very annoying problem:
Sometimes I have to return different object through the same api call, for example, if the file has a property ready and I want to test the user-flow to prepare a file to be ready I need to return the file with ready: false the first time, then I add some parameters, and then I have to return the file with ready: true. How can I do that?
Another example would be getting a single source file. I have the same api call api/source/:sourceId but when the source has ready: true it needs to have more parameters compare if the source has ready: false, but I don't know how to simulate that behaviour without a backend.
Right now the only thing I can do is to have a different response based on the query parameters:
mock.onGet(/dmd\.mocked\/api\/files/).reply((config) => {
if (typeof config.params !== 'undefined') {
switch (config.params.status) {
case 'queued':
return [200, ResponseObject.queuedFilesList];
case 'processing':
return [200, ResponseObject.processingFilesList];
default:
return [506];
}
} else {
return [200, ResponseObject.queuedFilesList];
}
});
but this approach works only if I make the call with different parameters. If I make the call without any parameters I don't know how to diversify the response.
I am trying to create a script for email verification. I mean when we create an account on the site, then a verification mail will come to the given mail address and then we have to go to that mail and verify it(clicking on the link/or fetching the code). I tried this solution. But I have got stuck on the specific error.
This is code which I am trying.
describe("Sample test case", function () {
function getLastEmail() {
let deferred = protractor.promise.defer();
console.log("Waiting for an email...");
mailListener.on("mail", function(mail){
deferred.fulfill(mail);
});
return deferred.promise;
}
beforeAll(function () {
browser.waitForAngularEnabled(false);
browser.get("https://mail.google.com/mail/");
isAngularSite(false);
browser.sleep(3000);
});
it("should login with a registration code sent to an email", function () {
element(by.id("username")).sendKeys("MyemailID");
element(by.id("password")).sendKeys("mypassword");
element(by.id("loginButton")).click();
browser.controlFlow().await(getLastEmail()).then(function (email) {
expect(email.subject).toEqual("BillPledge Email Verification");
expect(email.headers.to).toEqual("support#billpledge.com");
// extract registration code from the email message
let pattern = /Registration code is: (\w+)/g;
let regCode = pattern.exec(email.text)[1];
console.log(regCode);
});
});
});
and this is my conf file.
// An example configuration file.
exports.config = {
// The address of a running selenium server.
// seleniumAddress: 'http://localhost:4444/wd/hub',
// if we are using protractor's webdriver-manager locally, you cannot use selenium Address
// If the webdriver-manager needs to start a local server, you can use
selenium: 'http://localhost:4445/wd/hub',
seleniumPort: 4445, // Port matches the port above
// Capabilities to be passed to the webdriver instance.
capabilities: {
'browserName': 'chrome'
},
// Spec patterns are relative to the current working directly when
// protractor is called.
specs: ['./e2eTest/GmailTest.js'],
// Options to be passed to Jasmine-node.
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 300000
},
allScriptsTimeout: 200000,
onPrepare: function () {
global.isAngularSite = function (flag) {
browser.ignoreSynchronization = !flag;
};
browser.driver.manage().window().maximize();
//To generate the report.
let HtmlReporter = require('protractor-beautiful-reporter');
jasmine.getEnv().addReporter(new HtmlReporter({
baseDirectory: 'Results/Report'
}).getJasmine2Reporter());
let reporter = new HtmlReporter({
baseDirectory: 'Results/Report'
});
let path = require('path');
new HtmlReporter({
baseDirectory: 'Results/Report'
, preserveDirectory: false
, cssOverrideFile: 'css/style.css'
, takeScreenShotsForSkippedSpecs: true
, screenshotsSubfolder: 'images'
, jsonsSubfolder: 'jsons'
, takeScreenShotsOnlyForFailedSpecs: false
, gatherBrowserLogs: true
, pathBuilder: function pathBuilder(spec, descriptions, results, capabilities) {
// Return '<browser>/<specname>' as path for screenshots:
// Example: 'firefox/list-should work'.
return path.join(capabilities.caps_.browser, descriptions.join('-'));
}
, metaDataBuilder: function metaDataBuilder(spec, descriptions, results, capabilities) {
// Return the description of the spec and if it has passed or not:
return {
description: descriptions.join(' ')
, passed: results.passed()
};
}
});
let MailListener = require("mail-listener2");
// here goes your email connection configuration
let mailListener = new MailListener({
username: "myemailid",
password: "mypassword",
host: "imap.gmail.com",
port: 993, // imap port
tls: true,
tlsOptions: {rejectUnauthorized: false},
mailbox: "INBOX", // mailbox to monitor
searchFilter: ["UNSEEN", "FLAGGED"], // the search filter being used after an IDLE notification has been retrieved
markSeen: true, // all fetched email willbe marked as seen and not fetched next time
fetchUnreadOnStart: true, // use it only if you want to get all unread email on lib start. Default is `false`,
mailParserOptions: {streamAttachments: true}, // options to be passed to mailParser lib.
attachments: true, // download attachments as they are encountered to the project directory
attachmentOptions: {directory: "attachments/"} // specify a download directory for attachments
});
mailListener.start();
mailListener.on("server:connected", function () {
console.log("Mail listener initialized");
});
global.mailListener = mailListener;
},
onCleanUp: function () {
mailListener.stop();
},
};
But while executing the script I am getting following error. The error is:
Error: Please log in via your web browser:
https://support.google.com/mail/accounts/answer/78754 (Failure)
and
Failed: browser.controlFlow(...).await is not a function
I know I am doing some mistake but I am not able to figure out. So can anyone can help me in pointing out and solve it, not solve but at least some suggestion which can help in running this script perfectly.
Thanks
Try to use browser.wait(getLastEmail) instead of browser.controlFlow().await(getLastEmail()
Situation: We are running tests in several browsers using Nightwatch
(via Saucelabs; everything runs fine on Saucelabs).
Desired: we want to know which browser the test is currently running in so we can save screenshots including the browser name.
Is it possible to determine which browser is running the tests?
Its quite simple, when running a Nightwatch test, the browser (or client) parameter is passed in, eg:
module.exports = {
'Demo test GitHub': function (browser) {
console.log(browser.options); // this will output the browser details
browser
.url('http://www.github.com/dwyl') // visit the url
.waitForElementVisible('body'); // wait for the body to be rendered
.assert.containsText('body', 'do what you love') // assert contains
.saveScreenshot('dwyl_github.png')
.end();
}
};
The browser Object contains an options Object with the following form:
{ screenshots: true,
screenshotsPath: './node_modules/nightwatch/screenshots/1.0.20/',
skip_testcases_on_fail: true,
log_screenshot_data: true,
username: 'thisguy',
accessKey: 'notimportant',
desiredCapabilities:
{ browserName: 'internet explorer',
javascriptEnabled: true,
acceptSslCerts: true,
platform: 'Windows 10',
version: '11.0',
name: 'Github' } }
So we wrote a little helper function to format the name of the browser into a string we could include in the screenshot file name:
function userAgent(browser) { // see: https://git.io/vobdn
var a = browser.options.desiredCapabilities;
return (a.platform + '~' + a.browserName + '~' + a.version).replace(/ /g, '');
}
Which is then used as:
module.exports = {
'Demo test GitHub': function (browser) {
console.log(browser.options); // this will output the browser details
browser
.url('http://www.github.com/dwyl') // visit the url
.waitForElementVisible('body'); // wait for the body to be rendered
.assert.containsText('body', 'do what you love') // assert contains
.saveScreenshot(userAgent(browser) + '_dwyl_github.png')
.end();
}
};
Example filename: Windows10~internetexplorer~11.0~dwyl_github.png
The reason for using ~ ("tilde") as the word separator was so we can later split on this character in our screenshot viewer.
See: https://github.com/dwyl/learn-nightwatch for more detail.