-1

I've a custom script on a web server, the script is run by calling a web page from a browser, once the page is opened the script starts and the browser windows is updated with results. I use Firefox ver 22 and when the script is running you can see the small green circle on the browser tab. Sometime anyway the script crashes and you see the grayed square on the browser tab.

These times I see the status, then I update the data on the web and run the script again from the browser.

I would like to do it by code and I'd like to try to do it in perl.

Lot of work, I know.

I didn't try it yet, I was starting to think at it and I've seen that with mechanize you can call a web page.

But the first problem I see, and I've not found a clear answer, is is it possible to know the browser windows status by code ? I mean, when the script is running I see the green circle on the Firefox tab, and when the script crashes I see the grayed square. I there a way to recognize the browser windows status, having more tabs, from perl ?

TIA

Flx
  • 1
  • Your keyword is *desktop automation*. I'm voting to close your question because it's too broad. – daxim Jul 30 '13 at 23:42

1 Answers1

1

Assuming you mean a server-side script rather than some javascript running in the browser, then the term you are looking for is HTTP Status Codes. If your script crashes you are probably getting a 500 code. If it works then 200 (or 20x).

If you use WWW::Mechanize then the success() method turns this into a true/false you can check. You can get a full HTTP::Response too if you want to find out the details.

If you need to run javascript then you basically have to automate the browser, using Perl to start up Firefox (or whatever) and drive it. Here you'll want to use something like WWW:Mechanize::Firefox or the WWW::Selenium driver and its associated server etc.

Tip - start simple and add steps one at a time, checking results after each step. So - fetch first page - can you find the link you want? Click link - does it fetch a page with the expected title? There are associated Test:: modules that can help with this.

Richard Huxton
  • 21,516
  • 3
  • 39
  • 51