Page 1 of 1

Scripts Interacting With Browser Elements

Posted: Tue Apr 01, 2008 10:47 pm
by Nonsanity
I'd like to do some automation work using Revolution's browser, but it looks like the click command falls through the browser to the stack objects behind it, and fails to click the link or scripted object at that location on the page.

Is there some way to simulate the user actually clicking in the browser through Revolution scripts?

Posted: Fri Apr 04, 2008 4:40 pm
by Mark Smith
What platform are you using?

On windows, I believe the 'browserClick' message will report what was clicked on when the user clicks on an element in a browser window.

On macs, it doesn't. I've dealt with this by intercepting the browserBeforeNavigate message which gives you the url of the link that's been clicked, then issuing a revBrowserStop command to cancel the navigation, and done what I needed with the url.

Posted: Fri Apr 04, 2008 5:56 pm
by Nonsanity
Yes, I noticed that platform discrepancy in the docs, but that wouldn't have helped me anyway, since it's the reverse of what I need.

What I want the stack to do is open a particular page, and automatically click something on it, without the user having to do anything. If it was just a link I could scrape the URL from the page source and just point the browser to it, but that won't help if the clickable spot on the page executes local javascript code instead.

Beyond automation, this ability to force clicks and keypresses into the browser would allow for tutorials that can guide a user through a complex web interface and help them with oft-repeated tasks.

I'm beginning to think that there is no support for this in Revolution at this time. :(

And I primarily use OS X, but this project is for both Macs and Windows.

Posted: Fri Apr 04, 2008 9:18 pm
by Mark Smith
I see what you mean. No, I don't think you can do this.

Probably no help, but I have managed (once) to get rev to execute an applescript to execute javascript in a Safari window, but it's obviously not cross platform...

M

Posted: Fri Apr 04, 2008 9:54 pm
by Nonsanity
Hmmm... I wonder if anyone's ever made a plugin that can click on any other program. I've not gotten into Revolution add-ons yet, but this wouldn't have been too hard to put into an XCMD back in the Hypercard days of yore.

Posted: Sat Apr 05, 2008 11:42 am
by Mark Smith
If you were able to write XCMD for HC, you can probably do it for Rev - there's some documentation and demos available on the RunRev site - Mark Waddingham wrote a series of articles in the newsletter about it.

If you're on Macintosh only, you might look into the whole applescript/automator stuff.

Posted: Wed Apr 09, 2008 10:15 pm
by Nonsanity
Pew... Back then XCMDs were written in Pascal. Talk about old school!

For now I'm just shelving the project, and/or moving it to some other platform. Maybe someday it will be able to drive simulated clicks into the browser objects, at which point I'll try again.

Posted: Thu Apr 10, 2008 9:25 am
by Mark
Hi Nonsanity,

Simulating clicks is a bad idea anyway. As soon as the website changes, or the way of rendering by the web kit changes, your programme would stop working. If a user has different default fonts set or doesn't have installed necessary fonts, the website would display but your scripts won't work.

A better way would be to get the htmlText from the browser object and change this as if it had been clicked on. If necessary, Rev can contact the server, posting a form.

What exactly did you want that click in the browser object to do? If "something" (in your earlier post) is a click on a link, you can simply load the page the link links to. If you want the user to be able to see what you are doing, you can set the screenMouseLoc to move the mouse around, but this will probably be a big hassle, because of different ways of rendering.

Best,

Mark

Posted: Wed May 07, 2008 8:54 pm
by Nonsanity
Many web pages these days are interactive within themselves using javascript, for example. So clicking on something doesn't necessarily submit a form or open a link. For those cases, yes, I can parse the HTML and spoof a click. But in a javascript-driven calculator page - for an over-simplified example - clicking on buttons makes changes to the contents of the page. That's not something that can be spoofed.

In my case, the environment is tightly controlled, and the page in question is loaded with javascript actions. Differences in page rendering is moot, therefore, and spoofing isn't possible. Hence the desire to just do like the user does and click on stuff. :)

Posted: Wed May 07, 2008 9:06 pm
by Mark
Hi Chris,

If the page is not yours, the owner of the website may not want you to automate "user" interaction, but if this isn't a problem to the owner of the website, why don't you see if you can work something out together?

If it is your own website, it should be relatively easy to make this work.

Best,

Mark

Posted: Fri May 09, 2008 3:36 am
by alex298
Hi Mark,
If it is your own website, it should be relatively easy to make this work.
I am quite interested. Could you please provide some guidlines?

Thanks and best regards

Re: Scripts Interacting With Browser Elements

Posted: Fri Oct 02, 2020 10:26 am
by marco.deepak
Hi all,

Has the situation above been improved since 2008?.

Is it now possible to interact with browser elements in newer LC releases?.
Things like clicking on a browser element, or clicking on the element and writing something, drag and drop, ecc.

Thanks

M.