MichaelR
MichaelR

Reputation: 999

Right/Left mouse click on screen in watir webdriver

Is there a way to simulate a right/left mouse click at a specific location on screen?

Not element#click , but simply specify a location on screen ( 500 , 500 ) ?

Thanks.

Upvotes: 3

Views: 2223

Answers (1)

Eugene Rourke
Eugene Rourke

Reputation: 4934

@browser.execute_script("$(document.elementFromPoint(x, y)).click();")

UPDATE
The trouble is it may not do what you expect from right click

@browser.execute_script("$(document.elementFromPoint(2, 2)).trigger({type: 'mousedown', which: 3});")

it might be not so much about watir webdriver solution but should work

Upvotes: 4

Related Questions