Keyboard events in atom-shell - electron

I am trying to use atom-shell, but I don't understand how the DOM events differ from a normal browser. I can't find doc about it either.
If I add:
document.onkeydown = function() { alert('...'); }
to index.html, it seems that atom-shell doesn't capture the event, and instead forwards the call to the terminal in which I ran atom-shell myapp.
Is there any documentation somewhere about how the DOM events work in atom-shell?
Edit: This only happens when I run atom-shell from the terminal window (in OSX). If I run the app by first starting the Atom application and dragging my app inside the drag area, then it works fine...

It's a bug: here is the GitHub issue

Related

How to perform ctrl+j in ruby for chrome browser. I am using RubyMine and WatirWebdriver

Tried below code to click ctrl+J but did not work for chrome browser.
#browser.driver.action.key_down(:control).send_keys("j").key_up(:control).perform
Also tried
#browser.driver.action.send_keys(:control,"J").perform
I read in one blog, above code would work for Firefox browser but not for Chrome.
First off,
The way you send control+j is wrong. The way to send the control+j is,you have to give control+k inside the [] like [:control,"j]
b.send_keys([:control,"j"])
Second off,
it's not possible to send the [:control,"j] via chromedriver because of the following issue
https://bugs.chromium.org/p/chromedriver/issues/detail?id=903
The exact answer lies here
This is a limitation in the way we simulate keyboard input in ChromeDriver. Keys get sent directly to the render process, bypassing the browser process. So any keyboard shortcut handlers in the browser process will not be invoked by sendKeys().

React Native events do not work

I have a trivial react component that only shows a button:
<Button onPress={() => console.log("test")} title="Button"/>
When I put this button into a project I created with react-native init, it works as expected.
However, I have an existing project into which I integrated React Native (0.51.0) manually (because it doesn't use cocoa pods; I followed this guide: https://medium.com/#joshyhargreaves/adding-react-native-to-existing-ios-project-without-cocoapods-6f1ee9106009).
The project seems to work fine: the UI loads, the button gives visual feedback when I tap it. But the buttons onPress event is not fired, so it does not log anything.
There are no errors or warnings (except Class RCTCxxModule was not exported, but it seems to be safe to ignore this).
I'm now out of ideas of what I could try or how I could debug this issue short of diving into Reacts touch handling code. Here's what I tried:
Made sure to only have one RCTRootView, and that it is created in the main thread.
Checked for any suspicious things happening in the remote debugger; everything looks normal (no exceptions thrown or warnings logged).
Tested a few other components that should fire events; for example, TouchableOpacity does not work either.
Logging something after a timeout does work, so it doesn't seem like anything is deallocated prematurely
Checking for errors reported by the metro bundler: it doesn't print anything
Any ideas on what I need to do to get my button to print "test" when I tap it?
I think you have not Debug JS Remotely option enabled. If you don't you have to open React Native Debug Menu Pressing (command / control) + D or shake your device if you are debugging with real device. Then just press Debug JS Remotely and it should appear in the Google Chrome. Then inspect and open the console. There it is!
This mite caused by date diff between the host (your computer) and the client (the mobile device)
You can check this by running adb shell "date" && date
to see if there is a diff.
If there is one go to your mobile device and toggle automatic date & time off and back on.
Then test time diff again as mentioned, if there is no more diff, tap events should work in debug mode
More details in the original git issue answer by - Alex Ciarlillo

DOM ready event inside Electron how?

This is a silly question, but I could not find a clear answer on the web.
Do I need to listen to a special "dom-ready-event" if my app is running within a BrowserWindow in Electron? For instance in a Cordova/PhoneGap app I read you can start doing things after the deviceready event.
I would like to know how this is done in Electron? Is one of the following enough?
document.addEventListener("DOMContentLoaded", startApp);
window.addEventListener("load", startApp);
Thank you.
Cordova has deviceready because it has both native code and JavaScript code, and potentially JavaScript might run before the native code has finished loading.
You don't have the same problem in Electron. You have a main process (main.js) which creates your BrowserWindow, so by the time any client-side JavaScript is running, your main process has definitely already started because it was the thing that created your browser window in the first place!
Inside the browser window the same events fire as they would on a normal webpage. So if you wanted to, you could use DOMContentLoaded or load (for the difference see this article on MDN), just in the same way as you would for a regular web application. But you certainly don't need to before calling any of the Electron APIs.

Selenium IDE simulate press ENTER for javascript configmation box

I am looking for allready for hours how to do this. So don't tell me to use search function. I know there are many things related.
There is many stuff on the internet and here, but no one works for me.
And I need a solution for Selenium IDE or something intergrated with it (if there is anything). Not RC and not WebDriver etc.
I need to simulate a key for an JavaScript confirmation popup, which has "OK" and "Cancel" buttons.
The problem is that I cannot select anything.
Popup appears when the site is opened. The Website itself is visible in the background, but no element can be selected (Firebug shows nothing as well, empty html(?)).
If I press ENTER key the confirmation box disappear (so it works fine manually).
This example seems good, but I can't find any interface in Selenium IDE to do this:
driver.switchTo().alert().accept();
(from Click in OK button inside an Alert (Selenium IDE))
I have only the following pattern:
Or write the test in html, which uses the "Command", "Target", "Value" pattern.
Appreciate any help.
EDIT1:
With the link provided by Janesh Kodikara
I have found that my problem is:
Selenium IDE will not be able to handle alerts that are within the page's onload() function. It will only be able to handle alerts that are generated after the page has completely loaded.
There is no "onload" function in my website, but the script part which creates the alert is inside html which is called with page (not in any function). This must be the same as "onload", because the alert comes immediately when the website is opened.
Once you have a confirmation box, you must consume it (Click OK or Cancel button)
You can use "chooseOkOnNextConfirmation" command to instruct Selenium IDE to simulate clicking OK button.
See http://www.guru99.com/enhancing-selenium-ide-script.html for more details.
You will not see the Javascript popup when IDE script is run.
Selenium IDE
Command : runScript
target : {window.onbeforeunload=function(e){};}
Command :click
target : xpath of button.
This will work fine but you are not able to see popup.

DOM ready in Dartium

Calling focus() inside main() doesn't stick when Dartium is first run (OS X via Dart Editor). There is something async going on that changes focus to the URL bar. Works if Dartium already running. Is there some event I can hook to reliably set focus? Thanks.
Based on the comments in Issue 12283, seems like this would require changes in Chrome to fix. It's not clear if it's a bug, or missing feature, but I think the chances of it being addressed are probably slim :-/

Resources