Reputation: 61
Getting selenium java to click in the middle of the browser window.
I just need it to click in the middle of the window (so I can pause an embedded video).
Upvotes: 0
Views: 2457
Reputation: 2583
To click in the middle of the browser window:
Dimension window = driver.manage().window().getSize();
new Actions(driver)
.moveByOffset(window.getHeight() / 2, window.getWidth() / 2)
.click()
.build()
.perform();
but better provide locator of video to click directly on it, and not on abstract "middle of the browser window"
Upvotes: 1