Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to click on a specific coordinates of an element

I need click on a specific coordinates of a element with watir-webdriver. With selemium-webdriver it will be looks like:

@driver.action.move_to(element, 30, 0).click.perform

But how do it with watir?

like image 381
facetostool Avatar asked Feb 04 '13 11:02

facetostool


People also ask

How can we click element on 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 I click a specific element in 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.

How do you click coordinates in Javascript?

elementFromPoint(x, y). click();

How do you click on an element title?

We can find and click elements by title in Selenium webdriver. An element can be identified with a title attribute with xpath or css selector. With the xpath, the expression should be //tagname[@title='value']. In css, the expression should be tagname[title='value'].


1 Answers

I think you will have to access the selenium-webdriver driver directly (assuming browser is your watir-webdriver browser):

browser.driver

To get the underlining selenium-webdriver element for a watir-webdriver element, use wd (assuming element is your watir-webdriver element you want to click):

element.wd

Putting it all together, you would do:

browser.driver.action.move_to(element.wd, 30, 0).click.perform
like image 87
Justin Ko Avatar answered Oct 03 '22 02:10

Justin Ko