Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
72
rated 0 times [  77] [ 5]  / answers: 1 / hits: 35940  / 7 Years ago, thu, august 3, 2017, 12:00:00

I am using Selenium WebDriver and coding in Java. In a code I need to scroll down to a specific element in the web page for clicking it. I am using JavascriptExecutor command. My question is how will I get to know the exact x and y coordinates of that specific element as per the position of it in the web page. The syntax of the code I am using is given below:



JavascriptExecutor jse = (JavascriptExecutor) driver;
jse.executeScript(scroll(x,y));


In the second line of the above code I need to give the specific values for the x and y coordinates of the element I want to click.


More From » java

 Answers
24

I suggest you to give reference the element itself instead of its coordinates.



((IJavaScriptExecutor)driver).ExecuteScript(arguments[0].scrollIntoView(true);, element);


Hope this helps. Thanks.


[#56882] Monday, July 31, 2017, 7 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
gerardamosy

Total Points: 600
Total Questions: 116
Total Answers: 102

Location: Ukraine
Member since Tue, May 30, 2023
1 Year ago
gerardamosy questions
;