How to quit appium test session using Robot Framework? - appium

How to properly quit the automation session when running Robot Scripts?
I’m new to App automation. I was trying to automate one of my iOS application with Robot Framework and my setup was configured for running my test on a browser stack’s device.


The following is my sample script.
*** Test Cases ***
Open App
Open Application ${Remote_Url} platformName=${PlatformName} deviceName=${device}
... platformVersion=${os_version} app=${app} name=${name} build=${Build} orientation=${Landscape}
... autoAcceptAlerts=${AutoAcceptAlerts} browserstack.idleTimeout=${browserstack.idleTimeout browserstack.appium_version=1.21.0
Login in to app
Input Text id=txt-username my_username
Input Text id=txt-password my_username
Click Element id=btn-login
Wait Until Page Contains Element id=img-userprofile
Sleep 5
Close the app
Quit Application
But when I execute this script, it performs the automation steps perfectly, but the test status in the browser stack console is shown as "TIMED OUT" (Please see the second item in the below screenshot)
if I do the same automation steps via Appium Inspector, then the browser stack will treat this test as "Passed" and its status will be displayed as "UNMARKED" (the first item in the below screenshot).
I looked through the Robot Framework Appium library documentation and couldn't find any useful ways for terminating a session. So, could someone kindly tell me how to properly close a session and how to set the session status with respect to test result (my success/failure)?

You can use the below to end the session on BrowserStack
*** Test Cases ***
Appium Test on BrowserStack
Open Application ${REMOTE_URL} app=%{BROWSERSTACK_APP_ID} name=single_test build=RobotFramework platformName=iOS os_version=11.0 device=iPhone 8 Plus
# accessibility id=Alert Button
Click Element id=Alert Button
# accessibility id=OK
Click Element id=OK
Close Application
For your reference, below is the sample repository which you can use.
https://github.com/nithyamn/bstack-robot-framework/tree/master/app/test

Related

Blazor browser-side opens print menu

I am sending data from a .NET Core app to a Blazor client via a websocket , after which via the interop , the data gets in my component.
I do not understand why when i am trying Server-Side it works ok ,the app has the desired behaviour , while when changing the project to Browser i get a Print Menu pop-up like the one below. (I have some #define where i can choose at ease between Server-Hosted or Browser)
How can Blazor do this pop-up ?
When i press cancel on the print menu i get the following error in the browser:
blazor.webassembly.js:1 WASM: * Assertion at
/mnt/jenkins/workspace/test-mono-mainline-wasm/label/ubuntu-1804-amd64/mono/mini/wasm_m2n_invoke.g.h:547,
condition `0' not met
blazor.webassembly.js:1 Uncaught
(in promise) abort(). Build with -s ASSERTIONS=1 for more info.
How can blazor open a print menu ?
I do not understand why when i am trying Server-Side it works ok ,the
app has the desired behaviour , while when changing the project to
Browser i get a Print Menu pop-up like the one below.
Websockets are not supported on client-side Blazor. They are supported only on the server... Perhaps this is why your client-side Blazor misbehaves.

React PWA Image Upload in Mobile Safari breaks application?

We were surprised we didn't find any mention of this anywhere online, so we're posting here in hopes we find a solution.
Using an iPhone with mobile safari is when we hit this issue running the 2 easy to follow tests below, one works, one doesn't.
Here is the link
https://pwa-react.netlify.com/
Here are the 2 tests we run (both listed in the link), one works when not in PWA mode, and the other fails when in PWA mode.
Test #1: Works Perfectly (Expected Behaviour)
Visit https://pwa-react.netlify.com/ from iPhone in mobile safari
1. Make sure you have google drive on the phone but not logged in.
2. Click "Choose File". It will show you the list of options to choose from.
3. Click "Browse" to look for the photo.
4. Click "Cancel" and you're back here.
5. Click "Choose File" it will still show you the list of options to choose from.
This works perfectly in mobile safari but NOT in PWA mode below.
Test #2: Does NOT Work (Unexpected Behaviour) (PWA)
Visit https://pwa-react.netlify.com/ from iPhone in mobile safari, hit the share
button, then add to home screen. This will add the PWA app on your phone. Open App.
1. Make sure you have google drive on the phone but not logged in.
2. Click "Choose File". It will show you the list of options to choose from.
3. Click "Browse" to look for the photo.
4. When it shows you the Google Drive logo with Sign In, double click the home
button, then go back to the PWA.
5. Click "Choose File" it will NOT show you the list of options to choose from.
This is now 100% broken.
The ONLY way to fix it is to go to Settings>Safari>Clear History and Website Data (all the way down)
How can we fix this so when the user hits "Choose File" it shows the list of
options to choose from in the PWA?
Screenshot #1: These are the options that appear in Test #1 and stop appearing in Test #2
Screenshot #2: This screen allows us to cancel in Test #1 but it disappears in Test #2
Any idea how to get Test #2 to work by allowing us to choose the upload options like in Screenshot #1 without breaking the app and having to go to safari settings to clear history and website data for it to function again?
PS - Here is the repository file pwa-react/src/App.js
We were facing almost exactly the same issue in our PWA, so first, off I want to thank you for helping us narrow down the cause.
After reviewing the iOS PWA lifecycle (article here) and a couple maddening hours of trial and error I was able to figure out a solution that is semi-acceptable.
My guess at what is happening when you leave the app mid-upload (Test #2) is that there is some internal context in how iOS handles PWA's that is not being reset, so when you go back and try to upload a file again it thinks that the upload dialog is already open.
The article mentions that opening external links without target=_blank will cause the PWA context to be deleted, so when the in-app browser closes, the PWA page reloads in the standalone window. I thought that might reset the "detached upload" context, and it ended up working.
So I created a page hosted on another domain, and linked to it below our upload button in the PWA:
// not sure the target={'_self'} is necessary but not risking it
<a href={'https://externalDomain.com/reset'} target={'_self'}>
Having Issues? Reset Upload
</a>
This works decently well, minus one issue. When you click this link it opens the in-app browser, but there is no "Done" button or navigation tools for the user to know how to exit. Linking back to the PWA does not work, because iOS detects that and does not reset the app context. What I did notice was that if I navigated to another page from the first external page (I originally just tested this with google.com), the "Done" button would show up, making it obvious how to exit.
With that knowledge, I guessed that you could probably just do window.history.pushState to achieve the same effect, which works. My final solution is below. It causes the entire app to reload when the user presses Done from the in-app browser, but that's far better than having them re-add to the home screen in my opinion.
const Reset: React.FC = props => {
React.useEffect(() => {
// Redirect any wayward users who find this page from outside the PWA
if (!window.matchMedia('(display-mode: standalone)').matches) {
navigate('/');
}
// push an additional page into history
const newUrl = `${window.location.href}?reset`;
window.history.pushState({ path: newUrl }, '', newUrl);
}, []);
return (
<Grid container>
<ArrowUpIcon />
<Typography variant={'h5'}>Press done above to return to App</Typography>
<Typography variant={'body1'}>Sorry for the inconvenience!</Typography>
</Grid>
);
};
Hope this helps! Would love to hear if it works for you.
Edit After Production Testing:
An additional important note is that your "reset" page must be on a completely different domain for this to work. Ran into this today in production, because our reset page was on a subdomain with the same root as the PWA, iOS was not resetting the entire PWA lifecycle.
SUMMARY
Key Issues:
Leaving an iOS PWA while any of the "file upload" dialogs are open ('Take Photo', 'Photo Library', or 'Browse') breaks the iOS PWA lifecycle.This breakage makes it impossible for the user to open any "file upload" dialogs when clicking on a file input.
In order to fix this issue, the PWA context must be completely reset.
It seems that the only ways to reset the PWA context are to restart the phone, delete the app and re-add it to the home screen, or to open an external link.
When opening an external link, the "Done" button that closes the iOS PWA embedded browser will not show on the initial page. The user must navigate to an additional external page in order for the "Done" button to show.
External links do not trigger a reset of the PWA context reset when they have target="_blank".
Solution:
In order for the user to be able to upload files again, the PWA context must be reset. The easiest way to do this (in my opinion) is to ask them to open an external link.
(In PWA): Present a link to the user to fix the fact that the upload dialog is not showing. The link destination must be a completely unrelated domain (not a subdomain) and must have target="_self" (issue #5).
(External Page): Once the user clicks on the link and the external page opens, there will be no visible way to leave the page (issue #4). To resolve this, you can use history.pushState to simulate navigating to an additional page.
(External Page - Bonus): To make it clear to the user that the issue has been resolved, add an arrow in the top left pointing to the "Done" button (as shown in my screenshot).

Account Linking redirect in Actions on Google simulator

I'm building an app utilizing the new Action on Google Java API. As I understand from dealing with account linking in Alexa, the initial flow (when the userId in the JSON request is null) should redirect to a sign in form to elicit user consent:
#ForIntent("RawText")
public ActionResponse launchRequestHandler(ActionRequest request) {
String userId = request.getAppRequest().getUser().getUserId();
String queryText = request.getWebhookRequest().getQueryResult().getQueryText();
String speech = null;
ResponseBuilder responseBuilder = getResponseBuilder(request);
if (isBlank(userId) || GREETING.equalsIgnoreCase(queryText)) {
speech = "I've sent a link to your Google Assistant app that will get you started and set up in just several simple steps.";
responseBuilder.add(
new SignIn()
.setContext(speech));
//...
return responseBuilder.build();
While testing in the AoG Simulator, however, I'm not seeing any redirection being done. I'm seeing the following error:
My account linking setup:
where authorization URL redirects to a local mock auth service which is supposed to display a login form. It's accessible (both via localhost and via ssh tunnel, provided by serveo.net reverse proxy in this case). Why Google doesn't redirect me there?
Can someone please guide me how to do this initial handshake in the account linking flow and where can I see the form which the Sign-In intent sent from the web hook is supposed to trigger?
I'd rather not use my phone, as the error message seems to suggest, as the account under which I'm testing in AoG simulator differs from my user ID on the phone.
What is meant by using Simulator as a Speaker? What is missing in my setup?
Is there another Google app that simulates the physical device better, similar to Alexa's simulator?
Normally, you can simulate the account linking, by selecting the Debug tab, there you will find a url, copy-paste it on another tab and you can link your account.
Once linking is done, go to the simulator and type 'cancel' or 'stop', and then 'Talk to speech bank'.
! Don't press reset or Change Version, or you have to re-link your app
But, recently Google has removed this url from debug tab, and I can't find it anywhere...
Simulator as a Speaker, The Surface Dropdown is set to Phone, you need to select Speaker,
but when you try that one, you will receive this error...
Invocation Error
You cannot use standard Google Assistant features in the Simulator. If you want to try them, use Google Assistant on your phone or other compatible devices.
So for the moment, you can't test an Action that needs account linking, using the simulator. You can do it with your smartphone...
UPDATE 2019-03-05:
Google has added the account linking in the simulator, which is now easier to test.

Previewing rails server on AWS Cloud 9: VFS Connection does not exist [Firefox only]

Update: This is specific to Firefox. This does not occur using Chrome. I will leave the text below as is, but now the main question is, how and what in Firefox is causing this. It occurs regardless of cookie settings, such as allowing third-party cookies and trackers.
Preface: I've searched and read dozens of pages trying to resolve this issue I've gone through all the troubleshooting steps in the AWS documentation, eg,
https://docs.aws.amazon.com/cloud9/latest/user-guide/app-preview.html#app-preview-share
and this thread:
https://forums.aws.amazon.com/message.jspa?messageID=849200 as well as resources on stackoverflow
and the c9 forums
https://community.c9.io/t/what-is-vfs-connection-does-not-exist-on-aws-c9/22697/4)
I am trying to preview a running rails app from the Cloud 9 IDE. When I run the app using rails server, there are no error messages indicating anything wrong. The output shows Started GET '/' for [my home IP] ...... 200 Completed OK.
Console Output:
Trying to preview the running app only produces a "OOPS VFS connection does not exist" screen. The preview url is always https://[user_generated_sequence].vfs.cloud9.[region].amazonaws.com/ All TCP traffic is allowed as per the rules set up by following the troubleshooting guides.
OOPS error message page:
The same issue occurs whether using puma or WEBrick. With WEBrick, a popup for the preview link appears, but leads to the same error message page. With puma, the running app is listening on tcp://[localhost/0.0.0.0]:[8080 or 3000]. With WEBrick, it listens instead on http://localhost:8080.
I have followed the instructions exactly in the rails tutorial to set up a simple app. Everything in the code itself should be fine. How can I get this to work correctly? I'm very confused and about to give up on rails.
I recently had the same issues after updating Firefox because cross-site cookies are required to preview a running rails application. If, like me, you have disabled that in Firefox as part of strict Enhanced Tracking Protection, they will need to be enabled at least for this specific site.
Make sure you are accessing the preview from the same browser:
This URL works only when the IDE for the environment is open and the
application is running in the same web browser
https://docs.aws.amazon.com/cloud9/latest/user-guide/app-preview.html#app-preview-preview-app
Something that worked for me, do the following:
run:
rails s
the in the AWS EDE click on 'Preview' and 'Select Running Application'
Once it will open click on the button/link and it should open in another window with the running application.
Note: Doing this manually by copying the URL link and pasting in another tab did not work for me.
Try disable Ad Blockers and privacy Extention. It worked for me.
Basically you need to allow third party cookies
in chrome it's
Settings >> Security >> Cookies and web data >> Choose second option(block cookies only in incognito)
That works for me
On cloud9, click the shield logo in the address bar and switch "Enhanced Tracking Protection" to be off. Then refresh the page and the preview.
I was struggling with this as well. Finally, I changed the cookie setting from all third-party cookies to cookies from unvisited sites (See image)
Cookie Settings for Firefox

Automatically type text into text box and click button on iOS

I made an iOS app using Ionic Framework (https://appsto.re/cn/EY8s7.i). Is it possible to simulate user input to that app?
For example, user clicks QQ login button in my app, and my app opens the facebook authentication page inside the in-app browser. Now I want the app automatically fill the username and password to the authentication window and hit the "Login" button.
How can I achieve it?
I suppose you want to accomplish this to test your app and some of its functionalities?
If so, you should use Angular Protractor for this kind of testing.
Protractor is a Node.js program, and runs end-to-end tests that are also written in JavaScript and run with node. Protractor uses WebDriver to control browsers and simulate user actions.
Here's an example:
describe('TODO list', function() {
it('should filter results', function() {
// Find the element with ng-model="user" and type "jacksparrow" into it
element(by.model('user')).sendKeys('jacksparrow');
// Find the first (and only) button on the page and click it
element(by.css(':button')).click();
// Verify that there are 10 tasks
expect(element.all(by.repeater('task in tasks')).count()).toEqual(10);
// Enter 'groceries' into the element with ng-model="filterText"
element(by.model('filterText')).sendKeys('groceries');
// Verify that now there is only one item in the task list
expect(element.all(by.repeater('task in tasks')).count()).toEqual(1);
});
});
More info about this matter can be found at AngularJS end-to-end testing.

Resources