viewpoint-particle

Author Topic: Problems with IE11 Click Automation  (Read 2598 times)

apeacock

  • Newbie
  • *
  • Posts: 2
Problems with IE11 Click Automation
« on: April 22, 2015, 12:06:20 pm »
I have a WinBatch script that I'm trying to move from IE8 to IE11 (using WinBatch+Compiler 2012A).  It includes a click on a button defined as follows:

   <td>
      <input name="ign_choose" type="submit" value="Receive">
      <input name="use_gross" type="hidden" value="0">
      <input name="packageid" type="hidden" value="333333">
      <input name="lotno_prefix" type="hidden" value="M333333X">
      <input name="use_seqno" type="hidden" value="1">
   </td>

The original code gets the element object then used click.  That approach works, but the WinBatch script then hangs.  I can step through the script and complete the click line, but then script won't allow me to step forward any longer once the next page loads.  I have to use Ctrl+Break and stop the script at that point.

I've tried using some the newer click approach listed in some of the other posts:
   ... (msie1 is my IE object)
   msie1Element = msie1.document.getElementsByName("ign_choose").item(0)
   checkval = msie1Element.value  ;watch shows "Receive", as expected
   msie1Event = msie1.document.createEvent("HTMLEvents")
   msie1Event.initEvent("click", @TRUE, @TRUE)
   msie1Element.dispatchEvent(msie1Event)
   msie1Event = 0
   msie1Element = 0
However, this doesn't work (nothing happens in the browser).

Any suggestions on how to click the button without hanging the script?

Thanks!

td

  • Tech Support
  • *****
  • Posts: 2516
    • WinBatch
Re: Problems with IE11 Click Automation
« Reply #1 on: April 22, 2015, 01:05:20 pm »
I have a WinBatch script that I'm trying to move from IE8 to IE11 (using WinBatch+Compiler 2012A).  It includes a click on a button defined as follows:

   <td>
      <input name="ign_choose" type="submit" value="Receive">
      <input name="use_gross" type="hidden" value="0">
      <input name="packageid" type="hidden" value="333333">
      <input name="lotno_prefix" type="hidden" value="M333333X">
      <input name="use_seqno" type="hidden" value="1">
   </td>

The original code gets the element object then used click.  That approach works, but the WinBatch script then hangs.  I can step through the script and complete the click line, but then script won't allow me to step forward any longer once the next page loads.  I have to use Ctrl+Break and stop the script at that point.

I've tried using some the newer click approach listed in some of the other posts:
   ... (msie1 is my IE object)
   msie1Element = msie1.document.getElementsByName("ign_choose").item(0)
   checkval = msie1Element.value  ;watch shows "Receive", as expected
   msie1Event = msie1.document.createEvent("HTMLEvents")
   msie1Event.initEvent("click", @TRUE, @TRUE)
   msie1Element.dispatchEvent(msie1Event)
   msie1Event = 0
   msie1Element = 0
However, this doesn't work (nothing happens in the browser).

Any suggestions on how to click the button without hanging the script?

Thanks!

Another twist on  the IE-whatever-to-IE11-script-doesn't-work-now problem.    If I recall correctly, the click method will fail when using IE 11 objects unless you have set the page to be viewed in Compatibility View but I don't recall this problem ever causing the Click method to hang. 

Other than checking to make sure you are sending the event to the correct element, I don't see anything inherently wrong with your attempt at using the newer approach either.  Perhaps one of our IE11 browser object savvy forum members has an explanation.  I will check around a bit to see if I can gain any additional insights. 
"Success is a lousy teacher. It seduces smart people into thinking they can't lose."
  - Bill Gates


td

  • Tech Support
  • *****
  • Posts: 2516
    • WinBatch
Re: Problems with IE11 Click Automation
« Reply #2 on: April 23, 2015, 06:57:36 am »
I do recall that that MSFT changed the behavior of some of their getElementsBy* methods to conform to the W3C DOM with the IE 11 release.  I also know that this change has broken some scripts because at least one of the method was not returning the same elements it was with previous versions of IE.  What I don't recall is if getElementsByName is one of the getElementsBy* methods that was changed for IE 11.
"Success is a lousy teacher. It seduces smart people into thinking they can't lose."
  - Bill Gates


apeacock

  • Newbie
  • *
  • Posts: 2
Re: Problems with IE11 Click Automation
« Reply #3 on: April 23, 2015, 07:52:26 am »
I had originally used getElementByID in the IE8 script, which would return an element by either ID or Name.  In this case, since the element has no ID and Microsoft changed getElementByID so that it only returns elements by ID and not by Name, I had to change the code to use getElementsByName and then use the first element in the returned array.  I verified that this worked by checking the value of the element (that is the purpose of the "checkval" varialbe in my posted code).  Based on that information, I believe I'm sending the event to the proper element.

td

  • Tech Support
  • *****
  • Posts: 2516
    • WinBatch
Re: Problems with IE11 Click Automation
« Reply #4 on: April 23, 2015, 08:36:21 am »
Getting the 'value' of the element you expect does not in and of itself guarantee that you have the correct element. Hence the suggestion to make sure you have the correct element.   But since you can examine your site's complete DOM you can certainly verify the validity of the element you are using.

I don't have any other suggestions so unless some other forum member provides a new insight you will have to seek help elsewhere.   
"Success is a lousy teacher. It seduces smart people into thinking they can't lose."
  - Bill Gates