Get started with web macros in IE
Every web macro has to start somewhere, has to start somehow. There are basically two scenarios of automating Internet Explorer browser:
What can you do with a browser object? Quite a lot of things: navigate to a URL, find HTML elements and frames inside it, close the browser, get information about the browser, automate modal and modeless HTML dialgos and wait to complete navigation and loading.
That's all for now, but these feature will be covered in next tutorials!
Every web macro has to start somewhere, has to start somehow. There are basically two scenarios of automating Internet Explorer browser:
- start a new IE browser and navigate to a URL to begin with
- connect to an existing instance of Internet Explorer browser and continue automation
var core = new ActiveXObject('Twebst.Core');
var browser = core.StartBrowser('http://www.google.com/');
The code is quite self-explaining. It creates a Twebst object and then opens a given URL in a new IE browser instance. What you get back from StartBrowser call is a Browser object that can be used to further automate Internet Explorer.What can you do with a browser object? Quite a lot of things: navigate to a URL, find HTML elements and frames inside it, close the browser, get information about the browser, automate modal and modeless HTML dialgos and wait to complete navigation and loading.
That's all for now, but these feature will be covered in next tutorials!
(Automation Library and Macro Recorder for Internet Explorer)
5 comments:
Hi Adrian,
I have a problem, which is unrelated to this post, on which I would like to have some advice from you. Since I'm not sure how to get in touch with you directly I'm posting my problem as a comment!
The Problem is that in IE8 - the DocumentComplete event gets triggered twice for particular URLs because of which the logic suggested by MSFT here - http://support.microsoft.com/kb/q180366/ - does not work. I have even observed that the DocumentComplete event for iframes gets triggered after the DCE for the main document.
Hi,
Could you tell what is the URL causing trouble? I think that nowadays AJAX-ed web sites could trigger multiple "document complete" events.
Can you help me:
I am new to it.
Unable to create activex object for 'TwebstLib.Core.
Code:
First Try:
script type="text/jscript" language="jscript"
function LoadIE() {
alert('1 started.');
var core = new ActiveXObject('TwebstLib.Core');
alert('2 Core object');
}
/script
nothing happens, browser keep on procesing.
Second try:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Core = TwebstLib.core;
using ICore = TwebstLib.ICore;
using IBrowser = TwebstLib.IBrowser;
using IElement = TwebstLib.IElement;
using SHDocVw;
public partial class _Default : System.Web.UI.Page
{
[STAThread]
protected void Page_Load(object sender, EventArgs e)
{
ICore core = new Core();
IBrowser browser = core.StartBrowser("https://www.google.co.in/");
browser.FindElement("input text", "id=gbqfq").InputText("searchtext");
}
}
--
works when i run from VS2010 but when i publish the code and covert it to application in IIS its not working, browser keep on processing and nothing happens.
I wanted to busy this, and working on for POC.
I would be thank full to you, if anyhow you can help me in.
Hi,
From what I understand the first JS code runs on the client side in IE browser and the second runs on the server and it's asp.net
The first case won't work if the client does not have Twebst locally installed and it is subject to browser security restrictions (creating ActiveX objects from JScript).
The second point is still an unresolved issue. see: https://groups.google.com/d/topic/twebst-automation-studio/GZe96kLM9YU/discussion
Post a Comment