Tap event testing with protractor and appium - node.js

I have html with on-tap= doThis(). When going to test it with protractor and appium the .click event does not fire it off. It seems like a really simple thing to do, but yet I can not find any documentation on touch events for iOS appium. Does this have to do with the driver I am using?
// javascript
// assuming we have an initialized `driver` object for an app
driver.contexts().then(function (contexts) {
return driver.context(contexts[1]); // choose the webview context
})
// do some web testing
.elementsByCss('.green_button').click()
.context('NATIVE_APP') // leave webview context
// do more native stuff here if we want
.quit() // stop webdrivage

Related

Is there a way to configure "exit_on_all_closed" for browser tabs?

I'm currently working on understanding building Rust apps using Bevy in WebAssembly. Under normal circumstances, the exit_all_on_closed variable in the following code allows for the app to close when the window the app is launched in is closed.
fn main() {
App::new()
.add_plugins(DefaultPlugins.set(WindowPlugin {
window: WindowDescriptor {
title: "Extreme".to_string(),
..default()
},
add_primary_window: true,
exit_on_all_closed: true,
close_when_requested: true,
}))
.run()
}
Since I'm launching the app in my browser using a wasm server, I'd assumed that closing either the tab the app launches in or the entire browser would trigger the app exit, but it does not. Is there functionality in Bevy to handle that? Is there another work around?
Attempted: set exit_all_on_closed to true, launch app in browser, and close browser. Expected app to exit.
Actual result: Browser window closed but app is still running.
You can use the browsers beforeunload event via web-sys to track when users close a tab or a browser window containing your application.
Using this in combination with onload would also allow you to track all currently open instances.

How to implement idle timeout in Nativescript android application

I am building a Finacial application in Nativescript angular. I need some references like if the app is opened and running in the background after the set of some idle timeout it should redirect to the page which we specified. I couldn't get the proper reference in Nativescript can anyone please add a solution for the idle timeout. I have checked Nativescript extended activity but couldn't get properly
You should start by reading the documentation. What you need is Lifecycle hooks.
Read : https://docs.nativescript.org/angular/core-concepts/application-lifecycle#use-application-events
applicationOn(suspendEvent, (args: ApplicationEventData) => {
setTimeout(() => {
// do what you want after a certain amouont of time
// don't
}, 5000);
});
or
applicationOn(resumeEvent, (args: ApplicationEventData) => {
// compare current datetime with the last datetime saved in suspendEvent event
});
Don't forget your app can be force-closed, so you have to handle this depending on your needs

Rejoining a chrome.cast.Session in an ajax app?

Our site uses ajax to navigate pages and that's making it hard to request a new session when the page changes. Ideally when a user changes pages, I'd like to stop the currently playing session and start a new session with the video that's on the new page.
On the first pageload, I append the https://www.gstatic.com/cv/js/sender/v1/cast_sender.js script, call the init method:
var sessionRequest = new chrome.cast.SessionRequest(applicationID);
var apiConfig = new chrome.cast.ApiConfig(sessionRequest,
this.sessionListener.bind(this),
this.receiverListener.bind(this));
chrome.cast.initialize(apiConfig, this.onInitSuccess.bind(this), this.onError.bind(this));
everything works fine, my callbacks are called and I can start the chromecast session.
On secondary page loads, I don't re-add the cast_sender.js script. When I call the initalize method and the sessionListener callback doesn't execute. If I try holding on to the session between pages, I can access the session and get to it's media object, but if I try calling any methods on the session or media object, I just get back an error:
TypeError: Cannot call method 'postMessage' of null
Seems like there's some magic binding that happens when executing the cast_sender.js script that I'm missing?
We've just released the Google Cast extension Beta that potentially addresses this issue. See my post: https://plus.google.com/+ShawnShen/posts/aVXSHyceNbR
You may add something like the following in your app to do both sync/async script loading.
window['_onGCastApiAvailable'] = (function(loaded, errorInfo) {
if (loaded) {
this.init();
} else {
this.appendMessage_(errorInfo);
}
}).bind(this);

Detect My page rendering in Chrome App

I have followed this link ChromeApp for my chromeApp
I want to detect that Is my HTML page rendering on ChromeApp?
if(chromeApp){
//do this
}
else{
//do this
}
To answer the general question: Outside of the webview you can detect if you are rendering in a Chrome App by:
if (chrome && chrome.app && chrome.app.runtime)
// chrome app.
else
// open web.
(Taken from gapi-chrome-apps.js)
To answer the intent of the question, "How can detect and not show alert messages for content in a webview", you may wish to change the user agent and use that to detect. See this test code for more. Here's the idea, though:
webview.setUserAgentOverride(webview.getUserAgent() + ' in a webview');
Also, you can support alert dialogs with the change 19679002: : Implement dialog API (not quite in Chrome stable I think). The following should illustrate:
From the host:
webview.addEventListener('dialog', function(e) {
// Check e.messageType, e.g. it may be 'alert'.
// Use e.messageText
// Unblock the guest content wity e.dialog.ok();
});

Chrome Extension + Getting Hang while any dialogue comes while opening a page

I have created one extension to test my website, which will open page and do some activity like set text, get text etc etc.
I have created one C# application and via websocket I will communicate with extension.
In my extension I have added listener as below,
document.addEventListener('DOMContentLoaded', function() {
websocket.send(""); // Send signal to C# to execute next command
});
so when I will open any website e.g www.google.com, it will fire above event and my next action will come to execute, but issue is while I open any website which will have alert box at the first stage of loading page, will never execute above listener e.g If I will open http://www.crowderassoc.com/javascript/alertbox.html, it will give you an alert message, till your click on OK, the page will be busy and so It will get stuck.
I am created automated script, in which I will place one MSAA command to click on that "OK" button, but my it just got hanged.
Is there any option that I can make it work in this situation?
Move code of DOMContentLoaded Listener
document.addEventListener('DOMContentLoaded', function() {
websocket.send(""); // Send signal to C# to execute next command
});
in Content Scripts to listener of tabs.onUpdated or any of webRequest, webNavigation Appropriate Listeners in Background Page.

Resources