Forum Discussion

Pavel_1's avatar
Pavel_1
Contributor
14 years ago

Using Click and NativeWebObject.Click methods

Hi,


A was using  click method over the control on the web page ( ...Button.click() ) , but I've encountered with  some problems when using it on frames with scrollbars: when I use click method for control which is not visible on the frame (I should scroll down to see it) the frame content becomes damaged for some reasons after the click is performed, its like everything was scrolled down and the scrollbar disappeared. Tis happens occasionally and just in several places.


I found out that when I use click method of the NativeWebObject ( ...Button.NativeWebObject.click()  ), the page content is not crashed and click is handled correctly, but TestComplete hangs after performing this action for infinite time.


How can I avoid at least one of these problems, and what is the fundamental difference between using Button.click(), and Button.NativeWebObject.click()?


Thanks in advance

2 Replies

  • Hi,



    NativeWebObject.click is a native method assigned to some web objects. The regular Click method is added by TC to all on-screen objects. If you use NativeWebObject.click, your test may 'hang' in several cases - the most common one is when a click opens a modal dialog which causes a lock-up.



    To avoid problems, either call NativeWebObject.click asynchronously (see the "Calling Methods Asynchronously" help topic), or call the target object's scrollIntoView method before using the regular Click method.
  • Thank you Jared,


    You was right regarding the modal window, and calling method asynchronously did the job.


    And as for ScrollIntoView method, it caused the same troubles as regular Click(), I also tried MouseWheel() over the target object's parent but it also corrupts the section with scrollbar in case when the target object is out of the scrolled view.


    So now CallObjectMethodAsync is the best solution for me, thanks again.