elizaburkey
elizaburkey

Reputation: 61

Getting selenium java to click in the middle of the browser window

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

Answers (1)

Vitaliy Moskalyuk
Vitaliy Moskalyuk

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

Related Questions