Monitor and simulate javascript activity in .NET Webbrowser Control? - c#

Traditionally, if one wanted to monitor clicks in IE, you could do it by creating a Browser Helper Object. However, with modern javascript heavy websites (angularjs etc), the traditional click monitoring doesn't work.
Is it possible to monitor javascript clicks in the .NET Webbrowser Control? What if I wanted to simulate a javascript click? Use case is that I have the same site opened on two different .NET Webbrowser controls on two different PCs (both created by me). Lets assume the site is based on angularjs (or some other javascript framework), when the user clicks a link, dropdown etc, on machine A, I want to be able to send a command so that the same action is performed on machine B.

Related

C# Console Application WebBrowser

I have a normal console app .net core project with some classes, but I can't use a web browser. I want to navigate to a specified URL but with the web browser like in windows forms application, not just to start a process of my chrome. Like webbrowser.navigate function but I can't use it I don't know why?
Console applications are strictly text-based. Text in, text out, cursor position and not much else. They cannot have any UI controls or output. As such UI components such a text boxes, dropboxes, WebBrowser, etc. won't work as you expect if they work at all. While the console application may be hosted in a window (so you can see the output), your access is limited to what can be controlled via the Console class, which doesn't include any graphics or direct access to the window. See https://learn.microsoft.com/en-us/dotnet/api/system.console?view=net-5.0
Your only real options are to launch a browser (or other application), or convert your application to a non-console application capable of displaying graphical controls like WebBrowser.
It is technically possible to use WebBrowser in a console application (See https://www.codeproject.com/Questions/197007/How-Use-WebBrowser-without-winform), but be aware it won't actually display anything on screen, so it's use is limited.

Simulating mouse movement, without browser "head", to web server

I need to connect to a website programmatically, but without rendering the browser view, and then query the "headless" browser for certain page element's coordinate positions and send JavaScript events to simulate the movement of a mouse across the page form its current location to the new location.
I already have found a method that "realistically" moves the mouse programmatically between two points. All I need to do now is find a library that will allow me to connect to a page without the GUI but includes the positions of the page elements, but still query the JavaScript of the page and send JavaScript to the page's browser instance.
I know this very specific, but it will allow us to simulate our pages and test PHP heat mapping of the mouse location. It is also vital that this is for C#. Does such a library exist for C#?
Have you looked at Selenium? This can be run in headless mode, and has a very powerful API. I've used in C# for automated testing (including Javascript manipulation), and it works very well. It should be fine for scraping too though.

WebBrowser - Modal('Show') and Javascript

I'm using a standard WebBrowser control to perform various automated web requests. I am aware of the default IE 7 setting unless changed by registry, which I have done, and now use a mainly functional version of IE 10 embedded within my program.
Unfortunately, there are times when I need to click JS buttons to add data to the displayed webpage, and other times when there are Modal popups that require me to input information. Webbrowser chokes on this, and for the button, and popup, does nothing.
I am aware of the route of using ScriptInvoke to send my data, but I wondered if there is any way I can avoid this and just use the WebBrowser control as if it where a normal browser, that accepts the two described functions.
Thanks to all,
Stan.

Simulate keyboard on another web page from my web page?

I would like to display another web page within a web page... maybe using framnes, then be able to simulate mouse clicks/keyboard input randomally on this new page that is within my page.
Is this possible using asp.net/ javascript or any language. asp.net preferred
Thanks for any input
I dont think it is possible on client. If you are creating a desktop application then may be it could have been done like in automation, but on clint side even javascript cant create events like mouse clicks, it can only handle such events. however you can insert text in text boxes by traversing and accessing DOM in your javascript.
Its Definitely not possible from Server side in ASP.Net

Drag and Drop to a hosted Browser control

I have a WinForms program written on .NET 2 which hosts a webbrowser control and renders asp.net pages from a known server.
I would like to be able to drag, say, a tree node from a treeview in my winforms app into a specific location in the hosted web page and have it trigger a javascript event there.
Currently, I can implement the IDocHostUIHandler interface and getting drag\drop events on the browser control, then call Navigate("javascript:fire_event(...)") on the control to execute a script on the page. However, I want this to work only when I drop data on a specific part of the page.
One solution, I suppose, would be to bite the bullet and write a custom browser plugin in the form of an activex control, embed that in the location I want to drop to and let that implement the needed drag\drop interfaces.
Would that work?
Is there a cleaner approach? Can I take advantage of the fact that the browser control is hosted in my app and provide some further level of interaction?
Take a look at the BrowserPlus project at Yahoo.
It looks like they have built a toolkit so that you don't have to do the gritty work of writing the browser plugin yourself.
If you can find out the on screen position of the part of the page you are interested in, you could compare this with the position of the mouse when you receive the drop event. I'm not sure how practical this is if you can get the info out of the DOM or whatnot.
As an alternative could you implement the mouse events on the bit of the page using javascript?

Categories

Resources