Playwright on Mac does not support all keyboard shortcuts - testing

On a macOS, some of the shortcuts are available with playwright, such as: Meta+A, Meta+V.
However, undo and redo methods which are committed by Meta+Z and Meta+Y do not work.
await this.page.keyboard.down('Meta');
await this.page.keyboard.press('Z');
await this.page.keyboard.up('Meta');
Help will be greatly appreciated

Related

Combination of document.addEventListener and document.execCommand("copy") does not work in Safari

I have the following code, which works completely fine in Chrome/Edge/Firefox,
newest versions of course, but I expect even a few year old browsers of these will work just fine.
Now in Safari 15.3 (newest I think, at least very recent) this code does not work at all.
function copy() {
const copyListener = (event: any) => {
event.preventDefault();
event.stopPropagation();
event.clipboardData.setData("text/plain", "Random text data");
event.clipboardData.setData("text/html", "<div>Random html data</div>");
};
var eventListenerOptions = {
capture: true,
once: true,
};
document.addEventListener("copy", copyListener, eventListenerOptions);
document.execCommand("copy");
}
Let's imagine that this copy() function is called inside of a onClick handler.
Then after the onClick is triggered, then the document did register this eventListener, but it is just not triggered instantly by the document.execCommand("copy") call. It is only triggered when I after the copy() call select something manually on the screen and do ctrl+c.
So question time:
(1) I have heard somewhere that Safari does not emit a real copy event without any user interaction, which I guess I have confirmed sort of, it is user interaction to click on the button that calls copy() in its handler right? But maybe not the correct type of interaction. Is there any good official documentation on this? I tried to look at https://developer.apple.com/safari/ but it doesn't really provide you anything useful I think.
(2) I have seen code snippets around, and all of them for Safari uses range selections in the dom, and then call document.execCommand so an eventual solution for me is to use this as well, do a check to see which browser and then fallback to the range selection, I just do not think it supports any granularity in regards to "plain/text" and "plain/html" so I really want to avoid it because of that + less complexity if I could tweak this a little to make it work on all 4 browsers.
Any answers/comments are greatly appreciated, thanks !
Turns out that Safari does not support this idiom supported by Firefox/Edge/Chrome/etc.
There is a bug report that have not been active since 2019
https://bugs.webkit.org/show_bug.cgi?id=156529

WebdriverIO: Execution context is not available in detached frame

I'm trying to automate a flow that I've been doing at least once a day for the past 3 years. It's an unnecessarily convoluted process that is taking time out of my day. It's an internal proprietary system, so I can't give you any details about it, but suffice to say that I cannot change it. I have to try to automate it the way it is, and I'm stuck with the following error:
Execution context is not available in detached frame "https://..." (are you trying to evaluate?)
I'm using WebdriverIO with the default configuration, which uses Puppeteer internally. When I googled the error, I got a suggestion to add the following flags:
'--disable-web-security', '--disable-features=IsolateOrigins,site-per-process'
I did that, but it didn't help:
remote({
logLevel: 'trace',
capabilities: {
browserName: 'chrome',
'goog:chromeOptions': {
args: ['--disable-web-security', '--disable-features=IsolateOrigins,site-per-process']
}
}
})
I want to try it out in the REPL to do some more debugging, but I haven't figured out how to add those args when launching the REPL:
npx wdio repl chrome
Everything I've tried so far has failed. If someone knows how to do it, please let me know.
I don't do web automation normally and I chose WebdriverIO, since I have used it in the past for mobile automation. I'm wondering if this is a Puppeteer specific issue and if it would work in Selenium, but I'm not quite sure how to set that up. Puppeteer was just working out of the box.
Any guidance on how to get past this error would be greatly appreciated.
Turns out it was pretty simple:
browser.switchToFrame($('#iFrame'))
// Doing stuff inside the frame that causes the next page to show.
// Now that iFrame is gone and I have to switch out of it, to continue:
browser.switchToParentFrame()
// After the above call the execution context is not in a detached frame anymore.

PhantomJS process keeps running in background after calling program.kill()

I'm using phantomjs and webdriverio to fetch and render a webpage that's loaded by javascript, then save it to be parsed later by cheerio.
Here's the code for that:
import phantomjs from 'phantomjs-prebuilt'
const webdriverio = require('webdriverio')
const wdOpts = {
desiredCapabilities: {
browserName: 'phantomjs'
}
}
async parse (parseUrl) {
return phantomjs.run('--webdriver=4444').then(program => {
return webdriverio.remote(wdOpts)
.init()
.url(parseUrl)
.waitForExist('.main-ios', 100000)
.pause(5000)
.getHTML('html', true)
.then((html) => {
program.kill()
return html
})
})
}
Even though I call program.kill() I notice that the phantomjs in the list of processes, and it does use up quite a bit of RAM and CPU.
I'm wondering why the process doesn't terminate.
.close() just closes the window. There is a known bug, if it is the last window it stays open.
.quit() should do it, but there are issues associated with that as well.
PhantomJS bug report: https://github.com/detro/ghostdriver/issues/162
someone has a decent workaround posted at the bottom of that thread:
https://github.com/SeleniumHQ/selenium/issues/767#issuecomment-140367536
this fix shoots a SIGTERM to end it: (In python, but might be usefull)
# assume browser = webdriver.PhantomJS()
browser.service.process.send_signal(signal.SIGTERM)
browser.quit()
I like to just open a Docker container with my automation, and run it in there. Docker closes it up for me, however that is prolly out of scope for what you want to do.. i would recommend the above SIGTERM+quit method.
PhantomJS is a 2 component product. There is the Javascript which runs on the client (Whether web or other Script) side as part of your code. Then there is the part that runs as a server-side application (The command line call)
It has been my experience with PhantomJS that when an error is encountered, the PHantomJS server side "hangs" but is unresponsive. If you can update your call to this script to provide output logging, you may b able to see what the error is that PhantomJS application is encountering.
phantomjs /path/to/script/ > /path/to/log/file 2>&1
Hope this Helps! If you'd like me to clarify anything, or elaborate I'm happy to update my answer, just let me know in a comment, Thanks!

Get rid of "Remote debugger is in a background tab" warning in React Native

I've started a new React Native project and I keep getting the following warning:
Remote debugger is in a background tab which may cause apps to perform slowly. Fix this by foregrounding the tab (or opening it in a separate window).
It's a bit annoying so I wanna know how I can get rid of it? I'm running the debugger in Chrome and I moved it to a seperate window but it did not help.
If you have the Maintain Priority checkbox in the debugger window, try enabling it before you jump to any of the solutions below.
To get rid of the warning in your whole project add the following to your outermost Javascript file (most of the time that's index.js for React Native)
for react-native v0.63+:
Use LogBox:
https://reactnative.dev/docs/debugging#logbox
LogBox.ignoreLogs(['Remote debugger']);
for react-native v0.57 - v0.62:
import { YellowBox } from 'react-native';
YellowBox.ignoreWarnings(['Remote debugger']);
Reference this from the official React Native docs:
https://facebook.github.io/react-native/docs/debugging.html
react-native v0.56 or below:
Add the following early on in your code:
console.ignoredYellowBox = ['Remote debugger'];
Easy, simple and specific to that error. Works for me. Can substitute for any text you want.
this solution is work for me
open/move http://localhost:8081/debugger-ui (default path for remote debugging) on the separate window
maybe that could help :)
You can use React Native Debugger available at https://github.com/jhen0409/react-native-debugger It is a standalone app for debugging React Native apps during development.
Move http://localhost:*****/debugger-ui on the separate window.
Restart Remote JS Debugging.
For me warning went away by checking Maintain Priority Checkbox!
It is because of number of tabs are opened in the browser with React Native Remote Debugger UI tab. I also faced the same issue.
To overcome this warning message you can use any one method from the following:
Open an incognito tab then paste http://localhost:8081/debugger-ui on address bar and press ENTER. Finally reload the app (Command+R).
Close all the tabs in the browser. Keep only 1 tab opened then hit http://locahost:8081/debugger-ui then reload the app (Command+R).
As mentioned by #jakeforaker in one of the comment. The warning went away by simply opening the remote debugger in a separate window instead of a tab in your existing window of your browser (you have to reload your simulator though).
As the warning is saying keeping the remote debugger in the same window as other tabs
may cause apps to perform slowly
So i think simply suppressing warning as mentioned by #kjonsson:- console.ignoredYellowBox = ['Remote debugger']; doesnt seem to be best solution.
Since this commit in March 2017, you can enable the Maintain Priority checkbox. When enabled, it silently plays a base64-encoded .wav file to prevent the debugger's browser tab from entering low-power mode, which can affect websocket performance. This will effectively prevent the warning you describe.
This issue was resolved when I closed all open Chrome windows and started the Remove Debugging again. I had previously had open Chrome windows, so it 'seems' that having them open kills performance.
I think the accepted answer is no longer accurate (at least for React Native v0.57+).
The correct code is now:
import { YellowBox } from 'react-native';
YellowBox.ignoreWarnings(['Remote debugger']);
Reference this from the official React Native docs:
https://facebook.github.io/react-native/docs/debugging.html
I am on Macbook. I fixed this issue by bringing the Debugger window on main desktop, rather than on having it on separate desktop which it thinks is in "Background".
I had the same issue pop up yesterday. Googling it led to this Stack Overflow post. In one of the response (by adriansprod), he suggested:
Chrome debugger in it's own window fixes. But annoying problem
It is likely that your React Native debugger is not in its own Chrome browser window but in a Chrome browser tab. Pulling it out as its own window, as adriansprod suggest, fixed this for me.
The (very annoying) error message is handled by debuggerWorker.js, which sadly doesn't include any configuration options to turn off the message. So for the time being there are no ways you can configure your application to disable the message.
The related code is outlined below (original licence applies):
var visibilityState;
var showVisibilityWarning = (function() {
var hasWarned = false;
return function() {
// Wait until `YellowBox` gets initialized before displaying the warning.
if (hasWarned || console.warn.toString().includes('[native code]')) {
return;
}
hasWarned = true;
console.warn(
'Remote debugger is in a background tab which may cause apps to ' +
'perform slowly. Fix this by foregrounding the tab (or opening it in ' +
'a separate window).'
);
};
})();
As you see, no configuration options are used, the whole thing is scoped off locally (see the above repo link for further details).
I also have faced with same issue about one week ago and finally i have found solution that works excelent for me
It called reactotron, you can find it here - https://github.com/reactotron/reactotron and you can use it to:
* view your application state
* show API requests & responses
* perform quick performance benchmarks
* subscribe to parts of your application state
* display messages similar to console.log
* track global errors with source-mapped stack traces including saga stack traces!
* dispatch actions like a government-run mind control experiment
* hot swap your app's state
* track your sagas
I hope my post was helpful and you never will faced with this tedious warning .
Good luck
I use this in index.js
if (__DEV__) {
console.ignoredYellowBox = [
'Remote debugger',
'Warning: isMounted… is deprecated',
'Module RCTImageLoader'
];
}
I had minimised the "http://localhost:8081/debugger-ui/" window. Just opening it up (un minimising), and reloading the app removed the warning.
there might be chances that Another debugger is already connected to packager.
so close your terminal and debugger google chrome.
if you are using visual studio's package manger then don't start package manager by Mac/other os terminal command.
so close all terminal and stop on going package manger and google chrome debugger.
start the process again.
Similar to Akshay Vijay Jain, mine went away by ticking this box!

Are there any class in WinRT as MarketPlaceReviewTask in WP?

Are there any class in WinRT as MarketPlaceReview or MarketPlaceSearch Tasks in WP?
Thanks.
You can use Windows Store's protocol with specific arguments to launch several tasks related to Store like
If you want to open review page for any app then, you can open with this line.
await Windows.System.Launcher.LaunchUriAsync(new Uri("ms-windows-store:REVIEW?PFN=MY_PACKAGE_FAMILY_NAME"));
If you open the page of particular app in Store app then you can open with this line.
await Windows.System.Launcher.LaunchUriAsync(new Uri("ms-windows-store:PDP?PFN=MY_PACKAGE_FAMILY_NAME"));
MY_PACKAGE_FAMILY_NAME can be found in Package.appxmanifest file.
If you want to search within Store then you can open the Store app with search result with this line.
await Windows.System.Launcher.LaunchUriAsync(new Uri("ms-windows-store:Search?query=YOUR_SEARCH_KEYWORDS"));
The below are the examples which open review page for Nokia Music app, the app page itself & queries Store with text "nokia music" respectively.
await Windows.System.Launcher.LaunchUriAsync(new Uri("ms-windows-store:REVIEW?PFN=NokiaCorporation.NokiaMusic_6d0q6r3z979nw"));
await Windows.System.Launcher.LaunchUriAsync(new Uri("ms-windows-store:PDP?PFN=NokiaCorporation.NokiaMusic_6d0q6r3z979nw"));
await Windows.System.Launcher.LaunchUriAsync(new Uri("ms-windows-store:Search?query=nokia music"));
await Windows.System.Launcher.LaunchUriAsync(new Uri("ms-windows-store:Search?query=YOUR_SEARCH_KEYWORDS"));
In above answer, the line I pasted above here, It is not working in windows phone 8.1. query parameter is wrong, Here we need to use keyword as a parameter.
So, below is the code with right url.
await Windows.System.Launcher.LaunchUriAsync(
new Uri(string.Format("ms-windows-store:search?{0}={1}", type ,searchTerms)));
Please, check answer here.