Forum Discussion

nhanknight's avatar
nhanknight
New Contributor
12 years ago

Action "Click" doesn't work althought the button object is found




Hi all, I'm a new stater researching testcomplete tools. Could you please help me with my issue that I creates a script to login into smartbear support page by unitest VB script, but whenever I call click action, My script is stopped by error althought I used to tried to find button object that I want to click and the result is "object is found". Here is my script you can see that to more details. Thanks for your help very much.





sub Demo 





    dim browser 

    dim page 

    dim panel 

    dim defaultpage 

     

    Browsers.Item(btChrome).Run("http://support.smartbear.com/Samples/TestComplete9/WebOrders/Login.aspx") 

     

    set browser = Aliases.browser 

    set page = browser.Page("http://support.smartbear.com/Samples/TestComplete9/WebOrders/Login.aspx") 

     

    page.Wait() 

     

    set panel = page.Form("aspnetForm").Panel(2) 

      

    panel.Textbox("ctl00_MainContent_username").SetText("Tester") 

    panel.PasswordBox("ctl00_MainContent_password").SetText("test") 





    if  panel.SubmitButton("ctl00_MainContent_login_button").Exists then 

      log.Checkpoint("button exists")     

    else 

      log.Error("button not exists") 

    end if





    ' The result of above if script is true but action click this button is error

 

    panel.SubmitButton("ctl00_MainContent_login_button").Click 

        

    set browser = Aliases.browser 

     

    set defaultpage=browser.Page("http://support.smartbear.com/Samples/TestComplete9/WebOrders/default.aspx") 

     

    if defaultpage.Form("aspnetForm").Table(0).Cell(0, 1).Panel(0).TextNode(0).Link("ctl00_logout").Exists then 

      log.Checkpoint("Item exists") 

      defaultpage.Form("aspnetForm").Table(0).Cell(0, 1).Panel(0).TextNode(0).Link("ctl00_logout").Click 

    else  

      log.Error("Item not exists") 

    end if 

         

end sub







1 Reply

  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)

    Hi,


     


    I've modified your code a bit:


     


    ...


    if  panel.WaitSubmitButton("ctl00_MainContent_login_button", 3000).Exists then 


          log.Checkpoint("button exists")     


        else 


          log.Error("button not exists") 


    end if


    ...


     


    Does it work?