Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How it is possible click on specific coordinates with selenium2 webdriver in c#?

I'm using Firefox with my test but there is a problem when it comes to clicking flash buttons. I don't have access the source codes of flash elements, so i can't use flash-selenium or anything similar for test.

Currently my solution is getting a screenshot with windows api, and processing the screenshot and defining the button coordinates which I'm supposed to be click on it, then again with windows api clicking on the coordinates.

But in this way, i can't use my computer for anything else and i must wait for interacting pc unlike webdriver's own functions.

I'm trying to do getting a screenshot on Firefox page with webdriver (it's done actually), and getting in that screenshot the area coordinates of flash button and clicking on it without element based because when i use for checking if it's possible selenium ide, it can't click with functions like clickat or i am doing something wrong.

like image 671
mirza Avatar asked Mar 18 '11 03:03

mirza


People also ask

How can we click on an element at certain coordinates?

We can use the ClickAt command in Selenium IDE. The ClickAt command has two arguments − the element locator and the coordinates which mentions the x and y coordinates of the mouse with respect to the element identified by the locator.

How do you get the coordinates of an element in Selenium?

Selenium executes JavaScript commands with the help of the executeScript method. To get the unique coordinates of an element we shall create an object of the class Point which shall store the location of the webelement obtained from the getLocation method.

How do I click with Selenium?

We can click a button with Selenium webdriver in Python using the click method. First, we have to identify the button to be clicked with the help of any locators like id, name, class, xpath, tagname or css. Then we have to apply the click method on it. A button in html code is represented by button tagname.

What is Selenium moveByOffset?

The API syntax for the moveByOffset() method is as follows: public Actions moveByOffset(int xOffSet, int yOffSet) In the preceding code, xOffSet is the input parameter providing the WebDriver the amount of offset to be moved along the x axis.


1 Answers

In Selenium 2 you will be able to simulate moving the mouse to specified co-ordinates and click using the MoveToOffsetAction in the Advanced User Interactions API. This is currently still in development and not yet supported in the Firefox or Internet Explorer drivers.

More details of the Advanced Users Interactions API can be found on the project's official wiki page: http://code.google.com/p/selenium/wiki/AdvancedUserInteractions

like image 156
Dave Hunt Avatar answered Nov 03 '22 00:11

Dave Hunt