Forum Discussion

yabing's avatar
yabing
Occasional Contributor
8 years ago
Solved

Javascript PageObj.Confirm.Button("OK").Click() get Error "PageObj.Confirm.Button is not a function"

Hi,

 

I'm writing a javascript testing for a web UI against IE10 by using TestComplete 12. I want to click a confirm pop up window, but got "PageObj.Confirm.Button is not a function".

 

I use a function as:

PageObj.Confirm.Button("OK").Click();

 

I attached my screen shot and my code.

Somebody can help?

 

 

Thanks,

Yabing

  • Hi,

     

    I found that this function is not correct on SmartBear support document. It should be PageObj.Confirm().Button("OK").Click().

    We need a bracke after "Confirm".

     

     

    Thank you for your helps,

    Yabing

  • That's what was hinted at above... "Confirm" is a method on any web page that returns the Confirm object for that page.  So, if you are calling it, you need to add the brackets as you noted.

    HOWEVER, if you mapped the object using NameMapping/Aliases to specifically look for the Confirm object, then it is an object, not a method, and you don't need the brackets.

    The examples in the documentation probably do need a bit of a correction, but only to indicate that the confirm object in the examples has been mapped via NameMapping.

4 Replies

  • baxatob's avatar
    baxatob
    Community Hero

    Hi,

     

    More probably you have not mapped the button "OK". Check your NameMapping repository and update it if required.

    Currently .Button("OK") is considered as a function call.

    • tristaanogre's avatar
      tristaanogre
      Esteemed Contributor

      Couple of additional observations:

       

      The function you posted the code for does not indicate what "PageObj" actually is... is that a global variable somewhere, some other function call, etc?  Same thing with the "Confirm" child object... and, as has been pointed out, if you make a call like "Button("OK")" in JavaScript, it's going to try to execute "Button" as a function with a string parameter of "OK".

      So, somewhere in this process, you need to make sure the Confirm window is correctly mapped to the page object and the buttons on that window are also properly mapped as appropriate objects.

  • yabing's avatar
    yabing
    Occasional Contributor

    Hi,

     

    I found that this function is not correct on SmartBear support document. It should be PageObj.Confirm().Button("OK").Click().

    We need a bracke after "Confirm".

     

     

    Thank you for your helps,

    Yabing

    • tristaanogre's avatar
      tristaanogre
      Esteemed Contributor

      That's what was hinted at above... "Confirm" is a method on any web page that returns the Confirm object for that page.  So, if you are calling it, you need to add the brackets as you noted.

      HOWEVER, if you mapped the object using NameMapping/Aliases to specifically look for the Confirm object, then it is an object, not a method, and you don't need the brackets.

      The examples in the documentation probably do need a bit of a correction, but only to indicate that the confirm object in the examples has been mapped via NameMapping.