How to handle iOS popup in webdriverIO and mocha? - appium

I'm working on the Android and iOS app automation using the WebdriverIO. I'm unable to inspect the pop up in the browser stack inspect view.
Could you please assist on this?

I tired with browser.dismissAlert() and it worked.
In the page file I defined this function like
page.js
async popupHandle()
{
browser.dismissAlert()
}
In the test file I use it like
test.js
await page.popupHandle()

Related

Cordova Custom-URL-scheme plugin not working

The only plugin I can find is this one https://github.com/EddyVerbruggen/Custom-URL-scheme
I try to install it and check its iOS implementation, it is empty inside plugins/cordova-plugin-customurlscheme/src/ (no ios folder found, only android and window). I check the plugins/cordova-plugin-customurlscheme/www/ios/LaunchMyApp.js, the content is:
"use strict";
/*
Q: Why an empty file?
A: iOS doesn't need plumbing to get the plugin to work, so..
- Including no file would mean the import in index.html would differ per platform.
- Also, using one version and adding a userAgent check for Android feels wrong.
- And if you're not using PhoneGap Build, you could paste your handleOpenUrl JS function here.
*/
It doesn't make sense, based on my understanding, it should implement func application(_application: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:] ) -> Bool in the AppDelegate, but it is empty. In this case, how come overwrite handleOpenURL in the JS will work?
I really couldn't find others, can anyone advise similar workable plugin? My scenario is, when A app call B app, my B app is a cordova app, and I need a listener/callback to capture the url content.
Updated:
added in MAF tag, as the issue was caused by Oracle MAF framework, didn't expect that, thought the issue coming from Cordova.
It should not implement something in iOS. Custom URL scheme only updates Info.plist in iOS. So, it's fine. It REGISTERS custom URL schemes.
To handle the URL them you need to right your own code. How plugin will know what you need when custom URL is opened?
Alright, I know why there is no such implementation in https://github.com/EddyVerbruggen/Custom-URL-scheme
That is because in cordova-ios CDVHandleOpenURL.m, it already contained such implementation, it will consume the notification which is posted by the CDVAppDelegate.m, and in the CDVHandleOpenURL.m, it will execute handleOpenURL in the WebView JavaScript namespace.
The reason why my apps is not working, it is because Cordova was wrapped in the Oracle MAF framework, and it overwrite the custom URL mechanism provided by Cordova, which is not what I expected, so I forgot to mention MAF in my original question, I will add in related information.
reference:
https://docs.oracle.com/middleware/maf210/mobile/develop-maf/maf-ui-remote-url.htm#ADFMF24147

How to pass an argument to electron when using electron-builder?

I'm building an application with Electron and packaging with Electron Builder. When running electron, I want to pass this command line argument: --enable-mixed-sandbox.
Is it possible? How?
This:
app.commandLine.appendSwitch('enable-mixed-sandbox')
wouldn't work due to:
Note that it is not enough to call
app.commandLine.appendSwitch('--enable-sandbox'), as electron/node
startup code runs after it is possible to make changes to chromium
sandbox settings. The switch must be passed to electron on the
command-line:
electron --enable-sandbox app.js
It is not possible to have the OS sandbox active only for some renderers, if --enable-sandbox is enabled, normal electron windows
cannot be created.
You can use app.commandLine.appendSwitch in your applications main script (the one that opens the Electron window)
Example for your switch would be
app.commandLine.appendSwitch('enable-mixed-sandbox')
another way of doing it, you can use spectron to start the app in debug mode. which allows you to pass any arguments you want.
const Application = require('spectron').Application
// Returns a promise that resolves to a Spectron Application once the app has loaded.
// Takes a Ava test. Makes some basic assertions to verify that the app loaded correctly.
function createApp (t) {
return new Application({
path: 'path/to/app',
args: ['-r', '--enable-mixed-sandbox'],
env: {NODE_ENV: 'test'},
waitTimeout: 10e3
})
}
https://github.com/electron/spectron#new-applicationoptions
I got a response on that issue I raised and linked to in the comments:
app.enableMixedSandbox() // Experimental macOS Windows
See here for documentation.

how to get webview to work in dart

I want to use the webview tag in a chrome packaged app written in Dart,
I try to get the browser example inside the webview package to work
https://github.com/HannesRammer/webview
but when I set the webview attribute 'src', or call a function like 'back' using the jsinterop, it tells me unknown method back ... as far as I can see the package uses the correct jsinterop calls
maybe webview is not proper supported by jsObject, or what am I missing out ??
thanks :)
Make sure that you are running it as a Chrome App (right-click on the manifest.json in the Dart Editor and select "run as Chrome App"). The errors you describe sound like what you would see in a web app context, where the Chrome APIs are not available... also check that you have the webview permission in the manifest.json file.

Cordova resolveLocalFileSystemURL success call back failing on iOS

I've just created a new project and installed the file and file-transfer api's via CLI. I have already created a working app previously so I know how to use phonegap and have been doing so for a few years now.
Here is the code:
window.resolveLocalFileSystemURL("file:///localhost/var/mobile/Applications/96B4705C-C70D-4340-9A42-HJ1F28355D43/tmp/cdv_photo_015.jpg", function(fileEntry){
console.log(fileEntry.name);
}, function(error){
console.log('about to resolve this files errors');
console.log(error.code);
});
Nothing ever gets outputted in the console debugging window ...and yes I have debug installed cause I have console.log() in other parts of my code that show up.
It seems like there is an issue when passing URL data from navigator.camera.getPicture() to the file API when using window.resolveLocalFileSystemURL()...any ideas anyone. I'm up to date on phonegap api and everything and I have this issue for the past few days now...I can't seem to solve it.
***EDIT***
Seems like when you use Camera.DestinationType.FILE_URI as a parameter for navigator.camera.getPicture(). When you choose a picture and the success call back for navigator.camera.getPicture() is triggered, trying to window.resolveLocalFileSystemURL from the URL that getPicture returns just fails. But if you set Camera.DestinationType.NATIVE_URI it at least returns something but it's in a format that can't be used with the file-transfer api exp: assets-library://asset/asset.JPG?id=220BCEAE-F1EA-4A6A-83B2-AB8833A90BF2&ext=JPG
Seems like this was a bug in the file api v1.0.0
https://issues.apache.org/jira/browse/CB-6116
Temp solution is there as well.
Seems like "/local/" was causing the issue. Remove it from incoming uri's if it exist and the resolve should work.

Using Durandal with Phonegap/Cordova

I'm trying to develop a Cordova/Phonegap application using Durandal for IOS (using a Mac), and am having some trouble getting started.
I've got Cordova loading with RequireJs and that's all working fine. This is what I've got in my main.js file:
define(function (require) {
var
cordova = require('cordova.ios'),
system = require('durandal/system'),
//app = require('durandal/app');
document.addEventListener('deviceready', onDeviceReady, false);
function onDeviceReady () {
alert('Device is Ready!');
}
});
Notice I have app = require('durandal/app') commented out. If it IS commented out, then everything works fine. But as soon as I uncomment that, I don't get the alert anymore. I don't see anything out of the ordinary in the web inspector in Safari, and it seems like the app.js file gets loaded, but it stops everything else from happening there.
I know the docs say that you can use the optimizer, but is there no way to do the actual development in XCode and test without running the optimizer?
Thanks in advance for any help or ideas.
I believe there is an app variable in cordova, probably due to naming conflict. I created a sample and it worked with durandal. Please let me know if it doesnot work, i will post sample in github

Resources