I am trying to automate Internet Explorer interaction with a website using Python. I am using the IEC library to do this.
The website is set to trigger an action whenever a username is selected from a dropdown menu. The html code snippet is as follows:
<select name="ClientID" tabIndex="1001" title="Select a client" class="client-select focus-default need-focus-object valid" style="width: auto;" onchange="localChangeClient()">
<option value="0">
<option value="2629049">
I am able to programmatically set the user name in the dropdown list, but this does not trigger the "onchange" event. I have read some other references (links below) that indicate I should look for the AJAX request and trigger it directly, but I am not sure how to do this.
- Trigger Javascript event on remote website with Python
- on Change of dropdown list showld call the php function
I gather that 'onchange' triggers a call to a function called localChangeClient(). How do I call / trigger that function directly from Python IEC?
From the examples I linked, it seems an AJAX request would be made inside that localChangeClient function - is that right? How do I know what the AJAX request to call is, given that I cannot see the actual function details?
EDIT: The following describes continued efforts / developments. I think I just need to know how to call an AJAX URL directly
So I was reading more about AJAX requests. I found out I could use Firebug (Console window) to tell me the particular AJAX url that gets called for the onchange event. Firebug told me the following (snipped for clarity) when I changed the dropdown menu:
POST https://example.com/MyBasket/MyBasket.asp?update=Update%20Basket&ClientID=2629049,0&SDT=417.577989&SCheck=49913&Checkout=&ClientID=2629049&ClientID=0&CurrentPageUrl=&FullPage=false&MyBasketPage=1&OnClickScheduleCheckboxName=&OverlayRequest=true&TransactionStarted=0&ajax=true&cbxRegQuantity=1&cbxRegQuantity=1&update=no
So I think I am on the right track. But now I don't know how to trigger that url from Python. If I simply "ie.Navigate(url)", it does not seem to work. It takes me to a non-formatted window, and the dropdown menu is still not selected.
I checked a Microsoft support site (http://support.microsoft.com/kb/167658), which talked about encoding the request data as bytes etc, but I was unclear if that would apply here.
I would really appreciate if someone could provide some details on how to "do the AJAX request directly"