Activate Webpage Button Where 2 Have Same Name

  • Hi,


    I have a problem that I want to click a specific button on a webpage but there is different buttons with same name (in view source) but tabindex is different.I want to click a button where tabindex = 7.Any idea to do the specific task.


    Here is the button related HTML Code.



    Thanks in advance for helping me.

  • Re: Webpage Same Names Button


    Quote from Dave Hawley

    Why not identify the button by the ID?


    here is my code and it shows error Run time error 91:object veriable or with block variable not set.


  • Re: Activate Webpage Button Where 2 Have Same Name


    It's hard to debug this when we don't have access to the specific website, but it might be that you get the error due to the fact that the document is not fully initialized. If memory serves me right, the .ReadyState flag is not 100% reliable. If you put a Stop statement before assigning value to the Doc variable, wait for a good while for the page to load, and then continue the execution, does it work?

  • Re: Activate Webpage Button Where 2 Have Same Name


    Quote from Fencliff

    It's hard to debug this when we don't have access to the specific website, but it might be that you get the error due to the fact that the document is not fully initialized. If memory serves me right, the .ReadyState flag is not 100% reliable. If you put a Stop statement before assigning value to the Doc variable, wait for a good while for the page to load, and then continue the execution, does it work?


    No sir,Its still showing the same error message.Another clue for solving it.

  • Re: Activate Webpage Button Where 2 Have Same Name


    Hmm, I uploaded the bit of HTML you posted onto my server and tested it, getElementById finds the correct control.


    Here's how to do what you originally requested, but this is still just a workaround to the real problem. However that problem is really hard to troubleshoot without access to the webpage itself.


  • Re: Activate Webpage Button Where 2 Have Same Name


    Quote from Fencliff

    Hmm, I uploaded the bit of HTML you posted onto my server and tested it, getElementById finds the correct control.


    Here's how to do what you originally requested, but this is still just a workaround to the real problem. However that problem is really hard to troubleshoot without access to the webpage itself.



    Thanks for your quick reply but it has the same problem.

  • Re: Activate Webpage Button Where 2 Have Same Name


    What throws the error this time?


    Well, can you check the state of the Doc object upon the time of crash (take doc.body.innerHTML and compare it to the source of the web page - are these identical?)


    Other than that, I'm afraid I can't really help without being able to access the website.

  • Re: Activate Webpage Button Where 2 Have Same Name


    Quote from Fencliff

    What throws the error this time?


    Well, can you check the state of the Doc object upon the time of crash (take doc.body.innerHTML and compare it to the source of the web page - are these identical?)


    Other than that, I'm afraid I can't really help without being able to access the website.


    Do you mean I should check the viewsourc before error and after error or simply check viewsource through right click and through VBA and then make comparison.[hr]*[/hr] Auto Merged Post Until 24 Hrs Passes;[dl]*[/dl]

    Quote from Fencliff

    What throws the error this time?
    Actually this aour webbased software and only run on intranet so it can not be access out of the premesis.
    Well, can you check the state of the Doc object upon the time of crash (take doc.body.innerHTML and compare it to the source of the web page - are these identical?)


    Other than that, I'm afraid I can't really help without being able to access the website.


    Do you mean I should check the viewsourc before error and after error or simply check viewsource through right click and through VBA and then make comparison.[hr]*[/hr] Auto Merged Post Until 24 Hrs Passes;[dl]*[/dl]

  • Re: Activate Webpage Button Where 2 Have Same Name


    I mean that you should check the contents of the doc.body.innerhtml property to find out what exactly is loaded into the HTMLDocument object at the time of the error, and you should "view source" of the web page in a browser, and compare these two.


    The easiest way to inspect the .innerHTML property is to go to debug mode after the error throws, and in the immediate window type


    Code
    ?doc.body.innerhtml
  • Re: Activate Webpage Button Where 2 Have Same Name


    Hi,


    Your post above is empty - I think you might have exceeded the maximum length for your post.

  • Re: Activate Webpage Button Where 2 Have Same Name


    Sir,


    I am so confused because view source material is totally different according process doene by your opinion and now I use the Internet Developer Toolbar to show the different elements on the page but it shows me no such things i.e. images,buttons.input text etc.


    According to my understanding (Because I know a very little about IE and VBA integration)the orignal location is different and view source buttons on are another location so it is not clickable.So what should be the next step to do the task.Any helpful tutorials/site except of w3schools or any other material because simple html books do not learn integration with VBA.


    Sorry for bothering you.

  • Re: Activate Webpage Button Where 2 Have Same Name


    I don't actually quite understand what you're saying - do you mean that when you click "view source..." in your browser, it doesn't show you the same DOM (document object model) as IE Developer Toolbar? If this is the case, could you post the HTML you see when you click "view source.."? I'm thinking the website might be using frames, and would like to verify that.

  • Re: Activate Webpage Button Where 2 Have Same Name


    Quote from Fencliff

    I don't actually quite understand what you're saying - do you mean that when you click "view source..." in your browser, it doesn't show you the same DOM (document object model) as IE Developer Toolbar? If this is the case, could you post the HTML you see when you click "view source.."? I'm thinking the website might be using frames, and would like to verify that.


    Here is the viewsource file.Sorry for before bcoz I have not explore the developer toolbar.Now I am exploring it.

  • Re: Activate Webpage Button Where 2 Have Same Name


    Hmmm, could you do run the following code, and post the text from your Immediate Window:


  • Re: Activate Webpage Button Where 2 Have Same Name


    Hi,


    The reason why you keep getting the error is that the buttons aren't actually part of the main document displayed in the window, but an embedded IFrame object.


    You can try to change your code so that it refers to that embedded document:


    Code
    Set Doc = IE.document.frames(0).document


    However I can't see the contents of that embedded frame, because I don't have access to your system. This frame might contain more frames, which may contains more frames etc, in which case you might need to traverse the document.frames collection deeper:


    Code
    Set Doc = IE.document.frames(0).document.frames(n).document.frames '...


    Godspeed and good luck, unfortunately I can't help you any further.

  • Re: Activate Webpage Button Where 2 Have Same Name



    I have the following line with the help of webpage inspector programme


    Code
    document.all.WorkFrame.contentWindow.document.all.CustomerInfo.contentWindow.document.forms.Form1.btnContractSearch


    So what do you think now?Can I a click the desired button?

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!