Help automating internet explorer?

arcullarcull Member Posts: 191
Hi everyone. I wonder if anyone has some experience with microsoft internet explorer automation. What I'm trying to do is to simulate the browser actions from C/AL code. I would like to go to some address on the web, select the correct combobox value on it, press click on the page, and download the content of the new page. I've found something interesting suggestions on the web and produced the code below:
CLEAR(IEApp);
CLEAR(HTMLDoc);
CREATE(IEApp);
IEApp.Navigate('http://www.testpage.com');
WHILE IEApp.Busy DO;  //wait for the page to load
HTMLDoc := IEApp.Document;
WHILE IEApp.Busy DO;  //wait for the page to load
HTMLInputElement := HTMLDoc.getElementById('type_of_drink');
HTMLInputElement.value := 'juice';   //I get error here!!!
HTMLInputElement.click;
IEApp.Visible := TRUE;
Unfortunatelly I don't know how to select an item from the combo box on the page. On the page there is combo named type_of_drink, where you can select: water, juice or wine. I gues the only problem is how to fill or select the correct option form combo box. The vairables I used are:
Name	DataType	Subtype	Length
IEApp	Automation	'Microsoft Internet Controls'.InternetExplorer	
HTMLDoc	Automation	'Microsoft HTML Object Library'.HTMLDocument	
HTMLInputElement	Automation	'Microsoft HTML Object Library'.HTMLInputElement
Any suggestion, higly appreciated.

Comments

  • matttraxmatttrax Member Posts: 2,309
    Not really a web developer, but could it be like a Navision combo box? Where the caption is different than the value?

    So instead of setting the value to juice you would set it to 1. You can probably look at the HTML code and see if something like this is in there.
  • arcullarcull Member Posts: 191
    thanks matttrax, but I tried changing string to it's number value already, but that obviously isn't the source of problem. Maybe I didn't select the appropriate varible for the combo box, I've tried some of them, but none did work ok. Any other suggestion maybe?
  • jlandeenjlandeen Member Posts: 524
    Do you have access to view the source of the web page - it should have the accepted vales and their codes in it's definition. Depending on how the web pages and combo boxes are setup I think it is even possible to assign a code value to an item in a list (in Navision they're always integer based behind the scenes but on websites they can be code based).

    I believe in basic HTML you're loooking for a Select and Option tags. In the Option tags you should see a string value that exists behind the actual value displayed to the user.

    Also one other thing to check is that the case matches exactly. I think the HTML Automation controls are case sensitive.

    Just a few more suggestions :D
    Jeff Landeen - Sr. Consultant
    Epimatic Corp.

    http://www.epimatic.com
  • arcullarcull Member Posts: 191
    thanks jlandeen, but I gues the selection of the option value is not the problem, there must be something wrong with the usage of InputElement, it may be that it requires calling some other methods and assigning some properties, before the value property can be invoked. Well, I thought someone had some more practice with that. Thanks anyway for your suggestions.
Sign In or Register to comment.