vendredi 30 juin 2017

vba ie web scraper button click only works for some users on the site

I am having an issue which has been driving me crazy trying to figure out. We have a site at work that we have to pull large amounts of data from every day. I created a web scraper which works perfectly fine for me, but for some reason others have issues using the same site. I have ruled out it being a computer issue, because I have gone on their computer, logged in under my name on the site and it works perfectly fine.

The problem is, the "Next Page" click event doesn't work with some users. It finds the button, fires the click event and nothing happens. When I log in, it fires the event with no issue. I have tried everything to get it to work. I tried to use:

inputElement.FireEvent("onclick")
inputElement.click

I am unsure how a click event can work or not work via code based on who the user is. Physically clicking on the button still works, just not firing the onclick event via code for some users(it works for me, most importantly).

Here are the relevant parts:

Dim inputElement As HTMLInputElement
For Each inputElement In Document.getElementsByTagName("button")
    If inputElement.Value = "Next Page" Then
       Set inputElement = inputElement 'we set the next page button
       Exit For
    End If
Next inputElement
inputElement.Click

I have checked and the button is always the right button, no matter the user, so that isn't an issue. I have to loop through the buttons to find the right one because it has no id, name or class.

Any ideas? This one is really baffling to me.




Aucun commentaire:

Enregistrer un commentaire