question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is it possible to ExecuteJavaScript or emulate user actions like key pressing on loaded page?

See original GitHub issue

I am looking for solution to replace NightmareJs with c# implementation. The NightmareJs wraps electron api to allows not only to type or click but execute js as well i.e. win.webContents.executeJavaScript(src) WebContents does not provide such methods. Is there any equivalent way to do this?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
niklrcommented, Feb 24, 2019

I think what he means is similar to this question: https://stackoverflow.com/questions/28920621/how-to-call-a-javascript-function-on-a-web-page-rendered-by-electron

What is the equivalent to the following solution in Electron.NET?

app.on('ready', function() {

  ...

  mainWindow.webContents.on('did-finish-load', function() {
    mainWindow.webContents.executeJavaScript("alert('Hello There!');");
  });

  ...

});
0reactions
windhuancommented, Aug 27, 2020

i used LoadURL to exec javascript .

            browserWindow.WebContents.OnDidFinishLoad += () =>
            {
                browserWindow.LoadURL("javascript:alert('111')");
            };
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to simulate keypress action in javascript/jquery?
The events can be simulated, appending characters can be simulated, DOM events can be simulated. However, the user or the users device cannot ......
Read more >
How to simulate a keypress event in JavaScript
We use event handlers to simulate keypress events in JavaScript. An event in JavaScript, as the name suggests, refers to actions taken by ......
Read more >
How to simulate a click with JavaScript
Method 1: Using the click() method. The click() method is used to simulate a mouse click on an element. It fires the click...
Read more >
Handling Events
Imagine an interface where the only way to find out whether a key on the keyboard is being pressed is to read the...
Read more >
Browser clickpath events - Synthetic Monitoring
There are different event types to simulate interaction and control the clickpath, for instance, navigating to a URL, a click, selecting an option,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found