Ask a Question

How can i Scroll to view an element and click in TestComplete with Javascript?

SOLVED
funmay
Contributor

How can i Scroll to view an element and click in TestComplete with Javascript?

How can i Scroll to view an element and click in TestComplete with Javascript for web testing? Does TestComplete supports this control(Scroll into view element ).

 

See the example of selenium code controls  below:

 

var element = driver.FindElement(By.id("element-id"));

Actions actions = new Actions(driver);

actions.MoveToElement(element);

actions.Perform();

 

-------------------------------------------------------------------------------------------------

See the example of selenium code with Javascript:

(JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true);", element);

2 REPLIES 2
cunderw
Community Hero

FindChildEx would be similar to the driver.FindElement function, and element.scrollIntoView will allow you to scroll to the object. 


Thanks,
Carson

Click the Accept as Solution button if my answer has helped
AlexKaras
Champion Level 2

Hi,

 

Yes, scrollIntoView(true/false) is a native method that is supported by all browsers and can be used to scroll the element into view. Something like that:

var element = page.FindChild(...);

if (element.Exists)

{

  element.scrollIntoView(true);

  element.click();

}

 

Update: ah, just noted that I duplicated reply from @cunderw...

Regards,
  /Alex [Community Champion]
____
[Community Champions] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Champions]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Champion] signature is assigned on quarterly basis and is used with permission by SmartBear Software.
https://community.smartbear.com/t5/Community-Champions/About-the-Community-Champions-Program/gpm-p/252662
================================
cancel
Showing results for 
Search instead for 
Did you mean: