Change Combobox value in HTMl page from vb.net RRS feed

  • Question

  • Hi!
    I'm trying to automate one website using vb.net here and at 1 point I'm stuck.

    My app has 1 web browser control = myBrowser. Page loads in it and then I'll have to auto fill forms and invoke them to go to next page. By this stage I've already invoked scripts,submitted forms etc..no probs.. but now there's a little problem.
    You cannot see that page yourself since its my ISP's data usage check portal and it can be opened only from its connection. Further, this page is in client area.. so I cannot share username and password for it..

    This is how that HTML page is

    		<script language=Javascript>	
    			function myFunction()
    				var serviceName = document.getElementById("myComboBox");
    				var serviceNameValue=serviceName.value;
    					if (serviceName.selectedIndex != 0 ) 
    						//do nothing
    		<form name="myForm" method="post" action="test.php">
    				<input type="hidden" name="hidden_inpt" value="" id="serviceOrAccount">										
    				<select name="comboBox1" size="1" onchange="myFunction(this);" id="myComboBox">
    					<option value="0">Select</option>
    					<option value="Broadband">Broadband</option>
    				<input type=Submit value=Submit>													
    Here, on Combobox's selected index changed, they are calling one function which checks for hidden input value and then submits the form.
    If its selected as 'Broadband' then in same for there's one more combobox which will get a value from database.
    I tried setting setAttribute for hidden value. I can invoke the form but when next page loads I dont get that new value in 2nd combobox.

    what I want to do is, Change combobox1's index to 1. So that the function will get called and everything will happen on its own.
    I can use invokeScript method to call myFunction() and have the option selected even after navigating to next page.
    I think first way is easier..

    Tried doing many many things.. even appending new html element in Combobox1 with value Broadband and attribute selected :P.. didnt work..

    help! please :)

    Friday, May 8, 2009 4:08 AM


  • Oh god ! I did not THINK :-\

    myBrowser.Document.GetElementById("myComboBox").SetAttribute("selectedIndex", 1)
    Dim ObjArr(1) As Object
    myBrowser.Document.InvokeScript("getAccountNumbers", ObjArr)

    It was _that easy.. :-\
    Friday, May 8, 2009 4:20 AM