Why I can't dowload a file by click with Playwright - button

I create a csv-File on a server. Then I want do download by click to a button.
Manually it works fine. But if I click to download button by Playwright.
How is the right way to do that.
Thnak you for Help

You have this in playwright doc. Do the homework please.
const [ download ] = await Promise.all([
// Start waiting for the download
page.waitForEvent('download'),
// Perform the action that initiates download
page.click('button#delayed-download')
]);
// Wait for the download process to complete
const path = await download.path();
See playwright.dev/docs/downloads, as already mentioned

Related

Robot Framework Browser Library: Save and access PDF file returned by server

In my robot framework script I use the browser library to open a webpage and click on a button to get a receipt in PDF.
The button does not contain the direct link to the PDF: when you click the button, it opens a new page and after ~0.5 second the page returns a PDF file generated by the server.
I was not able to get and access the generated file in the Robot Framework script.
My tentative #1
I thought the PDF file could be captured by downloading it with a promise but it failed:
Click button.okButton
Switch Page NEW
${dl_promise} Promise To Wait For Download ./${SUITE_NAME}/downloads
${file_obj}= Wait For ${dl_promise}
File Should Exist ${file_obj}[saveAs]
Failure:
Tentative #1bis
${dl_promise} Promise To Wait For Download ./${SUITE_NAME}/downloads
Click button.okButton
Switch Page NEW
${file_obj}= Wait For ${dl_promise}
File Should Exist ${file_obj}[saveAs]
Same failure (TimeoutError: page.waitForEvent: Timeout 20000ms exceeded while waiting for event "download")
My tentative #2
The new page source code is the following:
<html><head></head><body><embed name="9AF27FA0E167C8860EB51FD926BE211B" src="about:blank" type="application/pdf" internalid="9AF27FA0E167C8860EB51FD926BE211B"></body></html>
I thought it is a local storage ID, am I right? So I tried the following:
Click button.okButton
Switch Page NEW
${sourceCode} = Get Page Source
${storageItem} = Get Regexp Matches ${sourceCode} (?<=(internalid="))(.*)(?=(">))
${myPDFfile} = Local Storage Get Item ${storageItem}
Log ${myPDFfile}
But seems it does not work:
... any idea how I should proceed? Thanks so much for your help and suggestions.
Keyword Promise To Wait For Download should be before triggering action. So the logic should be the following:
Promise
Trigger download
Wait for promise

React Native - Need to execute cloud function two time for it to work

I have a cloud function:
const deleteUser = async () => {
functions().httpsCallable('deleteUser')().then(response => {
console.log("Delete User Response -> ", response);
})
signOut();
}
Function works fine for iOS (built using swift) But for my react native app im using the code above.
But I need to run it 2 times for it to work.
E.g.
Press delete user button
User gets signed out (this is right but it
missed running the delete function)
I log back in Press delete user
button again
Signs me out
delete function runs (deletes the user) and shows me the following log
Delete User Response -> {"data": true}
Not sure why its not working the first time round?
The first time I try to delete the user (when it fails) I see the following in the terminal (these are not logs im printing)
Error: INTERNAL Error: INTERNAL

eHow to transition away from inline editor on actions on google

In a previous Stack Overflow question, I shied away from using an external webhook on Actions on Google
so I needed to go back to the inline editor. I got that worked out, but now I'm feeling brave again.
I've outgrown the inline editor and want the ability to develop my code on my laptop, testing it in Firebase, and publishing to a site for my webhook, presumably where the inline code editor publishes to. In fact, I have already written the require functions and deployed them from Firebase. So the full functionality is ready to go, I just need to hook it up properly to Actions on Google.
What I have now in Actions on Google, inline editor, is more of a stub. I want to merge that stub into my more fullblown logic that I have in Firebase. Here is what is in the inline editor:
const { conversation } = require('#assistant/conversation');
const functions = require('firebase-functions');
const app = conversation();
app.handle('intent_a_handler', conv => {
// Implement your code here
conv.add("Here I am in intent A");
});
app.handle('intent_b_handler', conv => {
// Implement your code here
conv.add("Here I am in intent B");
});
exports.ActionsOnGoogleFulfillment = functions.https.onRequest(app);
When I search on the Internet, I see discussion from the point of view of Dialogflow, but like I say, I'm in "Actions on Google". I want to transition away from the inline editor, taking what I already have, as a basis.Can someone explain how I set that up? I'm happy to do this within the context of the Google ecosystem.
To test your own webhook locally on your own system I would recommend incorporating a web app framework such as express. With express you can host code on your local machine and make it respond to request from Actions on Google. In your case you would replace this will all the code related to the Firebase functions package. Here is an example of what a simple webhook for Actions on Google looks like:
const express = require('express');
const bodyParser = require('body-parser')
const { conversation } = require('#assistant/conversation');
const exprs = express();
exprs.use(bodyParser.json()) // allows Express to work with JSON requests
const app = conversation();
app.handle('example intent', () => {
// Do something
})
// More app.handle() setups
exprs.post('/', app);
exprs.listen(3000);
With this setup you should be able to run your own application locally. The only thing you need to do is install the required dependencies and add your own intent handlers for your action. At this point you have a webhook running on your own machine, but that isn't enough to use it as a webhook in Actions on Google because it runs locally and isn't publicly available via the internet.
For this reason we will be using a tool called ngrok. With ngrok you can create a public https address that runs all messages to your local machine. This way you can use ngrok address as your webhook URL. Now you can just make as many code changes as you want and Actions on Google will automatically use the latest changes when you develop. No need to upload and wait for Firebase to do this.
Just to be clear: Ngrok should only be used for development. When you are done with developing your action you should upload all your code to a cloud service or host it on your own server if you have any. A (free plan) ngrok URL usually expires every 6 hours. So its not a suitable solution for anything other than development.

Ionic3 OneSignal How to check if app is launched because of a notification open event

I would like to know if there is a way to find out if an app is launched because of a notification opened event.
Currently when a user taps on an incoming notification, OneSignal will resume/launch my application and it will call the handleNotificationOpened handler of the app where I can process the notification without any problems as well as redirect the user to specific page in my app based on the notification's payload.
The issue that I want to solve is that if my application is not running, then OneSignal will launch the app and it will show the default root page of my app for less than a second and then the user will be redirected to the proper page. What I would like to achieve is to prevent showing the app's root page and only show the notification handling page upon clicking on the notification, thus I need to know if there is a way to identify the fact that the app was launched because of a notification tap.
Does anybody have an idea on how to achieve this?
Thanks
As I wasn't able to find a way to check launch parameters or anything like that to verify that the application was launched for processing a notification tap I tried tackling the problem from another angle.
For anyone interested in a possible "workaround" I have posted a possible solution. Please do not assume this is a definite solution but rather treat it as a suggestion and by no means do not push this onto your production environment without exhaustive testing.
constructor (platform: Platform, private statusBar: StatusBar, private oneSignal: OneSignal) {
var isNotification = false;
platform.ready().then(() => {
this.statusBar.styleDefault();
setTimeout(() => {
if (! isNotification) {
this.rootPage = FirstRunPage;
}
},3000);
var iosSettings = {
kOSSettingsKeyAutoPrompt: false,
kOSSettingsKeyInAppLaunchURL: false
};
this.oneSignal.startInit('replace with Onesignal id');
this.oneSignal.inFocusDisplaying(this.oneSignal.OSInFocusDisplayOption.Notification);
this.oneSignal.iOSSettings(iosSettings);
this.oneSignal.handleNotificationOpened().subscribe((data) => {
isNotification = true;
this.nav.push("NotifyHandlerPage");
});
this.oneSignal.endInit();
});
}

How can I get the URL in Google AppMaker?

I am trying to get the current URL in an AppMaker app. However, the standard JavaScript ways do not work, ScriptApp is not available in AppMaker, and the objects that are in AppMaker do not return the correct URL (that starts with https://script.google.com).
Thanks for any suggestions.
You can run a backend/serverside script and use Apps Script
ScriptApp.getService().getUrl()
See the doc ScriptApp Documentation
To have an app URL on client side, you can load it during app startup. Firstly, let's create server script that returns app URL:
/**
* Get the URL of the published web app.
*/
function getAppUrl() {
return ScriptApp.getService().getUrl();
}
Open your Project settings and put next code to App startup script section:
loader.suspendLoad();
google.script.run.withSuccessHandler(function(url) {
appUrl = url;
loader.resumeLoad();
}).getAppUrl();
Now you are able to use appUrl everywhere in Client Scripts.
Using this approach you can create initial app config on startup that requires specific data from server.

Resources