I am very new to MSHTML and DOM. I know this is a C# forum, but my problem may have a similar solution to the original posting by Irma.
I am trying to write a test harness that automates actions to our product's web-based management server. I am writing the code using Visual C++ 6.0. I also have IE 6.0.* installed, so I presume I have the "latest" MSHTML.dll.
I am able to do the login screen, and programmatically click on all the <a> anchor links. I can also programmatically click on Button elements that I find. However, I am having difficulty with no events firing when I change values for SelectOption elements, radio buttons, etc.
Here is an example of some HTML that I try to programmatically select and set:
<SELECT VALIGN=TOP class='data' id=RecPerPage onchange='ChangeRecPerPage()'>
<OPTION Selected= 10 VALUE=10>10</OPTION>
<OPTION VALUE=25>25</OPTION>
<OPTION VALUE=50>50</OPTION>
<OPTION VALUE=100>100</OPTION>
<OPTION VALUE=10000>All</OPTION>
</SELECT>
I am able to get the DOM object for the Select element and the Option elements. I can set the Option, and the Web Browser does show that I set the option. Here is a code excerpt:
SetOptionElement(IHTMLSelectElement& prSelect, const char pOptionName)
{
...
BSTR text;
ptroption->gettext(&text);
CString text_str = text;
if(textstr.Find(pOptionName) >= 0)
{
BSTR value;
ptroption->getvalue(&value);
prSelect->putvalue(value);
Sleep(1000);
return true;
}
...
}
However, the "ChangeRecPerPage()" function does not get called, so the frame does not refresh (with the new rows per page listing). I did an Ethereal trace and found that no HTML was posted, as it happens when one manually selects an option in that Select.
Does anybody have ideas about what is going wrong? I would think this is a very basic type of operation to automate this type of input element setting.
Thanks!
Enter your message below
Sign in or Join us (it's free).