I faced this problem writing UI test when test just can't finish and there is no default timeout for this. I can set this when creating casper instance like this
var casper = casper.create({stepTimeout: 5000});
But I can't do this when I launch casper in test mode casperjs test test.js. I have an error Fatal: you can't override the preconfigured casper instance in a test environment.
Is there any way to set this timeout in test environment?
There is already a preconfigured casper instance in test mode (casperjs test ...), so you can't create another with casper.create().
Use this : casper.options.waitTimeout = 10000; and casper.options.stepTimeout = 10000;
I used a global constant TIMEOUT in my methods to accomplish this
if(ADD_DONATION){
casper.click(DONATION_ADD_TAB);
casper.waitForSelector(DONOR_WEIGHT_ID, function success(){
test.pass('Add Donation --> Donations Loaded Successfully') },function timeout(){
test.fail('Add Donation --> Donations page timeout')},**TIMEOUT**);
}else
test.pass('Add Donation -- No Permission to view Add Donations Page');
});
Related
I am trying to implement caching for a SPFX WebPart using #pnp-Storage. The caching is working alright in the Temas browser but in the Teams client, it isn't working. It is very slow as I have to make multiple azure function call. Can someone please help me with caching in the Team's app. Please refer the code below.
// Getting data from session variable
This.isListsExists = this.storage.session.get(isListsExists);
// If it exists in the session variable then don't make the HTTP call. Otherwise, make the
// call and save it in the session variable.
if (!this.isListsExists) {
this.isListsExists = await this.mapDataProvider.checkIfAllListsExist(); //cache
// Setting Session variable.
this.storage.session.put(isListsExists, this.isListsExists, end);
}
I was using session storage and it wasn't working with teams but when I changed it to local storage it worked like a charm.
// Edit - Cache code
this.isListsExists = this.storage.local.get(isListsExistsCache);
// console.log("isListsExists - " + this.isListsExists);
if (!this.isListsExists) {
this.isListsExists = await this.mapDataProvider.checkIfAllListsExist(); //cache
this.storage.local.put(isListsExistsCache, this.isListsExists, end);
}
I first tried this
let url = await pa.getPageURL("Employees");
console.log("URL "+url);
Then I tried this. Both are throwing time out error but printing the correct url.
it('should be able to open Employees page',async () => {
loginPg.login();
pa.getPageURL("Employees").then(function(url){
console.log("URL "+url);
expect(url).toContain("employees");
})
})
async getPageURL(pageName){
this.menu.click()
let url = element(by.xpath('//span[contains(.,"'+pageName+'")]')).click().then(function(){
return browser.getCurrentUrl();
})
return url;
}
I'm writing a test where it clicks on a page link from the menu and assert the url. It works fine and click the link and goes to the correct page.
I have also verified that the console.log is correctly printing the url in the above code. But it fails everytime with Timeout error.
Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.
at ontimeout (timers.js:475:11)
at tryOnTimeout (timers.js:310:5)
What am I missing here? All my other tests work fine. Please help!
Try using a return keyword before your expect.
And also make sure to check DEFAULT_TIMEOUT_INTERVAL it will be 5 secs by default. Try changing it to 10 secs. So,That time is sufficient for logging in and then proceeding with actual expect.
I have an app where I want to select a person from contacts and then send a text to that person. It works as expected for the first user, but after that the app never receives control after the contact is selected. I've isolated the problem to the Nativescript-phone plugin. If you simply call phone.sms() to send a text, and then call contacts.getContact(), the problem occurs. I see this on both Android and iOS.
I've created a sample app that demos the problem at https://github.com/dlcole/contactTester. The sample app is Android only. I've spent a couple days on this and welcome any insights.
Edit 4/21/2020:
I've spent more time on this and can see what's happening. Both plugins have the same event handler and same request codes:
nativescript-phone:
var SEND_SMS = 1001;
activity.onActivityResult = function(requestCode, resultCode, data) {
nativescript-contacts:
var PICK_CONTACT = 1001;
appModule.android.on("activityResult", function(eventData) {
What happens is that after invoking phone.sms, calling contacts.getContact causes control to return to the phone plugin, and NOT the contacts plugin. I tried changing phone's request code to 1002 but had the same results.
So, the next step is to determine how to avoid the collision of the event handlers.
Instead of using activityResult event, nativescript-phone plugin overwrites the default activity result callback.
A workaround is to set the callback to it's original value after you are done with nativescript-phone.
exports.sendText = function (args) {
console.log("entering sendText");
const activity = appModule.android.foregroundActivity || appModule.android.startActivity;
const onActivityResult = activity.onActivityResult;
permissions.requestPermissions([android.Manifest.permission.CALL_PHONE],
"Permission needed to send text")
.then(() => {
console.log("permission granted");
phone.sms()
.then((result) => {
console.log(JSON.stringify(result, null, 4));
activity.onActivityResult = onActivityResult;
})
})
}
I have a bot with the following conversation scenario:
Send text to LUIS
LUIS intent calls context.Call(...) to launch a Dialog
This dialog terminates, save some info in the userData:
private static async Task storeBotData(IDialogContext context, BotData userData)
{
Activity activity = (Activity)context.Activity;
StateClient sc = activity.GetStateClient();
await sc.BotState.SetUserDataAsync(activity.ChannelId, activity.From.Id, userData);
}
And after it call another dialog, again with context.Call(...).
Then the last dialog runs and terminates.
My problem is that when updating the user data at the end of the first dialog (step 3), I have the following exception in the Bot Framework Channel Emulator:
`Exception: The data is changed [File of type 'text/plain']`...
What happens here ? I think that when a dialog terminates, it call setUserData by itself, but I don't understand why I can't update userData anywhere in the code...
I have tried to catch the exception, but nothing is catched.. But I know that the userData is updated, because when I try to retrieve it back, it is updated...
Any help is welcome :)
Thanks
Botframework restores/saves state of conversation after each act of activity, so under the covers typical flow looks like the following:
[23:15:40] <- GET 200 getUserData
[23:15:47] <- GET 200 getConversationData
[23:15:47] <- GET 200 getPrivateConversationData
...
[23:16:42] <- POST 200 setConversationData
[23:16:42] <- POST 200 setUserData
[23:16:42] <- POST 200 setPrivateConversationData
As it is mentioned here : These botData objects will fail to be stored if another instance of your bot has changed the object already. So in your case the exception occurs at the termination of dialog, when framework calls setUserData by himself and figures out that the BotData has been changed already (by your explicit call of BotState.SetUserDataAsync). I suppose that's why you were not able to catch the exception.
Solution:
I used the following code and it fixed the issue:
private static void storeBotData(IDialogContext context, BotData userData)
{
var data = context.UserData;
data.SetValue("field_name", false);
}
The reason it works is that we modify the object of UserData but allow botFramework to "commit" it himself, so there is no conflict
I agree with #Artem (this solved my issue too, thanks!). I would just add the following guideline.
Use
var data = context.UserData;
data.SetValue("field_name", false);
whenever you have a IDialogContext object available, so you let the Bot Framework commit changes.
Use instead
StateClient sc = activity.GetStateClient();
await sc.BotState.SetUserDataAsync(activity.ChannelId, activity.From.Id, userData);
when you don't have an IDialogContext object, e.g. in the MessageController class.
Hi I need to implement keep login in my sencha touch application
Please see my code below:
Login.js - Once user click login, it will store "sessionToken" in local storage.Then it will go to main Page
onBtnLoginClick: function(){
var loginviewGetValue = Ext.getCmp('loginview').getValues();
var bbid = Ext.getCmp('bbID').getValue();
var bbpassword = Ext.getCmp('bbPassword').getValue();
var LoginLS = Ext.getStore('LoginLS');
LoginLS.add({
sessionId: 'sadsadsadasd'
,deviceId:'1'
,bb_id :bbid
});
LoginLS.sync();
var mainForm= Ext.create('bluebutton.view.Main');
Ext.Viewport.setActiveItem(mainForm);
App.js~ Everytime launch function will check sessionToken in localStorage. If Localstorage is empty then it will go to login page.Else it will go to main Page
launch: function() {
// Destroy the #appLoadingIndicator element
Ext.fly('appLoadingIndicator').destroy();
// Initialize the main view
var LoginLS = Ext.getStore('LoginLS');
LoginLS.load();
var record = LoginLS.getAt(0);
if(record != undefined){
var sessionId = record.get('sessionId');
if (sessionId !=undefined){
Ext.Viewport.add(Ext.create('bluebutton.view.Main'));
}
else
Ext.Viewport.add(Ext.create('bluebutton.view.Login'));
}
else{
Ext.Viewport.add(Ext.create('bluebutton.view.Login'));
}
// Ext.create('bluebutton.view.TopMenuList');
},
Logout.js~Logout will clear the sessionToken and go to login page again
onLogoutClick: function scan() {
var LoginLS = Ext.getStore('LoginLS');
Ext.Viewport.setMasked({
xtype: 'loadmask',
message: 'Loading...'
});
LoginLS.load();
var record = LoginLS.getAt(0);
LoginLS.removeAll();
LoginLS.sync();
//Load a new view
// Ext.getCmp('tabpanel').destroy();
var loginForm = Ext.create('bluebutton.view.Login');
Ext.Viewport.setActiveItem(loginForm);
Ext.Viewport.setMasked(false); // hide the load screen
But i having a problem now. I not able to go back login page. It go to the blank page. Please give me some solution. Thanks.
Here is the error i get
[WARN][Ext.data.Batch#runOperation] Your identifier generation strategy for the model does not ensure unique id's. Please use the UUID strategy, or implement your own identifier strategy with the flag isUnique. Console.js:35
[WARN][Ext.Component#constructor] Registering a component with a id (`loginview`) which has already been used. Please ensure the existing component has been destroyed (`Ext.Component#destroy()`. Console.js:35
[WARN][Ext.Component#constructor] Registering a component with a id (`bbID`) which has already been used. Please ensure the existing component has been destroyed (`Ext.Component#destroy()`. Console.js:35
[WARN][Ext.Component#constructor] Registering a component with a id (`bbPassword`) which has already been used. Please ensure the existing component has been destroyed (`Ext.Component#destroy()`. Console.js:35
[WARN][Ext.Component#constructor] Registering a component with a id (`btnLogin`) which has already been used. Please ensure the existing component has been destroyed (`Ext.Component#destroy()`. Console.js:35
[DEPRECATE][bluebutton.view.Login#show] Call show() on a component that doesn't currently belong to any container. Please add it to the the Viewport first, i.e: Ext.Viewport.add(component);
Looking at the error messages it is clear that you are trying to create login panel again without destroying existing component. Error comes because you are not allowed to use same id more than once in application.
To avoid this you should not create same view multiple times, you should reuse views which is good for performance also. One more thing, you should give id to n element if and only if you can't do without it.
Assuming you cannot avoid id attributes you should do one of these 2 things:
Create new view only if it doesn't exist
var loginView = Ext.getCmp("loginview");
if(!loginView){
loginView = Ext.create('bluebutton.view.Login');
}
destroy login view as soon as it is out(hide/erased) of viewport by calling:
var loginView = Ext.getCmp("loginview");
loginView.destroy();
Use itemId for your components instead of idand reference them accordingly in you Controller. Check this question out: Warning saying `Id` exist and should be destroyed