Scripts Interacting With Browser Elements
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Livecode Opensource Backer
- Posts: 86
- Joined: Thu May 17, 2007 9:15 pm
- Location: Maryland, USA
- Contact:
Scripts Interacting With Browser Elements
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?
Is there some way to simulate the user actually clicking in the browser through Revolution scripts?
-
- Posts: 179
- Joined: Sat Apr 08, 2006 11:08 pm
- Location: London, UK
- Contact:
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.
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.
-
- Livecode Opensource Backer
- Posts: 86
- Joined: Thu May 17, 2007 9:15 pm
- Location: Maryland, USA
- Contact:
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.![Sad :(](./images/smilies/icon_sad.gif)
And I primarily use OS X, but this project is for both Macs and Windows.
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.
![Sad :(](./images/smilies/icon_sad.gif)
And I primarily use OS X, but this project is for both Macs and Windows.
-
- Posts: 179
- Joined: Sat Apr 08, 2006 11:08 pm
- Location: London, UK
- Contact:
-
- Posts: 179
- Joined: Sat Apr 08, 2006 11:08 pm
- Location: London, UK
- Contact:
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
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
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
-
- Livecode Opensource Backer
- Posts: 86
- Joined: Thu May 17, 2007 9:15 pm
- Location: Maryland, USA
- Contact:
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.![Smile :)](./images/smilies/icon_smile.gif)
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.
![Smile :)](./images/smilies/icon_smile.gif)
~ Nonsanity
~ Chris Innanen
~ Chris Innanen
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
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
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
-
- Posts: 11
- Joined: Fri Oct 02, 2020 10:24 am
Re: Scripts Interacting With Browser Elements
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.
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.