Page 1 of 1

Call JavaScript Function in HTML page

Posted: 29 Nov 2017, 14:40
by DanRobott
Hello everybody!

I´m developing a robot to copy data from a HTML web page.

The page contains DIVs that shows/hides some information.

The <A HREF> (HTML Code) calls a JS function to show/hide that information.

Is there a way from the "CODE" Action to interact with the page and call that JS Funtion?

I tried to create a new object from the window and used this code, but it didn't work:

Code: Select all

function(Call_JS){
	var btnCtrls=document.getElementsByTagName('A');
	for(i=0;i<btnCtrls.length;i++){
		if(btnCtrls[i].text=='QUERY'){
			btnCtrls[i].click();
			break;
		}
	}
}
Thanks in advance!
:wink:

Re: Call JavaScript Function in HTML page

Posted: 30 Nov 2017, 11:59
by eureka
I don't yet interact with web pages (Selenium does that) but I gave some thought to how I might approach this.
Normally I would use curl to scrape web page content.
Is the web page under your control or created elsewhere?

In Chromium browser I read about creating a new extension.
I followed the example here to register an example extension.

https://developer.chrome.com/extensions/getstarted

This creates a clickable button "Getting started example" in browser top bar which can trigger access to html dom.

Would this approach work for you? You would use Actiona to target the button icon in browser.

Re: Call JavaScript Function in HTML page

Posted: 30 Nov 2017, 18:07
by DanRobott
That´s a great idea!
I´ll have a try...
Thanks a lot for the support!

Re: Call JavaScript Function in HTML page

Posted: 30 Nov 2017, 18:32
by eureka
I've remembered another extension which I installed for testing.

http://chrome-automation.com/