How can i click on allow on firefox microphone popup in protractor? - popup

I want to click on Allow when firefox browser microphone popup will display. I have attached the screenshot of popup window. I have tried browser.switchTo().alert().accept() but in console i got error that No modal dialog is currently open in protractor. So how can i do that?enter image description here

Allow microphone is a browser alert. Only way to handle it is to use flag in your config file to bypass the alert shown as below:
For chrome it would be '--use-fake-ui-for-media-stream'.
For firefox :
FirefoxProfile firefoxProfile = new FirefoxProfile();
firefoxProfile.setPreference("media.navigator.streams.fake", true);
FirefoxOptions firefoxOptions = new FirefoxOptions();
firefoxOptions.setProfile(firefoxProfile);
capabilities.merge(firefoxOptions.toCapabilities());

Related

macOS native coding with browsers, how to open a url in existing tab from obj-c/swift?

I've developed a command palette for macOS. Over the last few days I've figured out a way to show the Notification Center inside my app.
I would like to mimic the behaviour of the real Notification Center when clicking a notification: open the corresponding tab when clicking in a browser notification.
However whenever I cannot figure out a way to do it programmatically, I can only tell macOS to open the link and it automatically opens the default browser and creates a new tab.
let url = URL(string: "https://www.google.com")! // this opens a new tab everytime
if NSWorkspace.shared.open(url) {
print("default browser was successfully opened")
}
As for the notification itself I do get all the info it contains: the app bundle id, the notification payload, and even a link (e.g. n#https://web.whatsapp.com#465718293123#c.us). I've seen some answers that rely on AppleScript but I would rather avoid it if possible. But if not possible... then happy to fallback to it.
Any ideas how to achieve this? Many thanks!
P.D. I've also tried some variations of the link such as: arc://web.whatsapp.com#1234567 or arc://n#web.whatsapp.com#1234567. At most this focuses on the browser but not on the tab.

How can I receive return data from a HTML popup on Flutter Web

I am working on a plugin that launches a WebView to carry out some auth verification. Using the webview_flutter plugin, it works fine on Android and iOS once I call the runJavascriptReturningResult function. It returns the document.getElementById('return').innerText and then I parse the result. But on Flutter web, the webview_flutter_web does not currently support runJavascriptReturningResult, so it throws a platform error once invoked.
I tried using an HTML Popup, but I don't know how to extract the return data before the popup closes.
My implementation for the popup is like this:
html.WindowBase _popup = html.window.open(url, name,'left=100,top=100,width=800,height=600');
if (_popup.closed!) {
throw("Popups blocked");
}
How do I get the return data before the popup closes? Is there another way to do this on Flutter Web?
Maybe listening beforeunload event on the new window and getting the return value before it closes.
The solution was to listen to onMessage. Then get the event data from it.
html.window.open(url!, 'new tab');
html.window.onMessage.listen((event) async {
log(event.data.toString()); // Prints out the Message
});

File uploading in fultter webview

I am using fluter webview for android and iOS apps. In the app, the page contains an HTML form where one of the fields is file uploading via dropzone.
If I open the page in the browser and press the Choose File button, file chooser pops up and everything is working fine, but when I press the Choose File button in the webview nothing happens.
I am following this github issue initiated by flutter developers - https://github.com/flutter/flutter/issues/27924
Any ideas how to make this work?

Hard browser refresh using nwjs on Mac

Is there a way to do a hard browser refresh when running an app with nwjs, on Mac? nwjs's right click 'simulate browser restart' seems to start the app at its entrypoint again. Is there a way to simulate the behavior of simply clicking the shift reload button in Chrome?
There is an nwjs api for this:
// Load native UI library
var ngui = require('nw.gui');
// Get the current window
var nwin = ngui.Window.get();
// this will do a hard refresh
nwin.reloadIgnoringCache();
// here's a regular refresh
nwin.reload();
nwjs doc:
http://docs.nwjs.io/en/latest/References/Window/#winreloadignoringcache
just use javascript reload
location.reload();

Closing an opened window on mobile safari with javascript?

In app mode, if I open a new window using javascript, the newly-opened window cannot close itself (on an on-click event) using the standard window.close() or self.close(). Does anyone know if there's an alternate method?
What I find most beguiling about this is that it goes against Apple's very own design guidelines: essentially a site has the ability to open a new window but the user cannot get out of it without closing the webapp using the Home button.
Any ideas? Thanks!
JavaScript:window.self.close() is how to do that.
you can try this js code snippet.
var win = window.open('','_self');
win.close();