hsac-fitnesse-fixtures
hsac-fitnesse-fixtures copied to clipboard
Need to set browser window position.
Testing web apps that download files requires interaction with desktop to deal with file-save pop-ups. This can be done though awt, with Robot, etc., but only if the pop-up button coordinates are known.
The position of the pop-up is only consistent when the browser location is the same. A new command is needed (using desktop coordinates), positionBrowserXY():
| position browser X | x-coordinate | Y | y-coordinate |
code example:
public void positionBrowser(String xStr, String yStr)
{
WebDriver aDriver = getSeleniumHelper().driver();
String currentWindowHandle = aDriver.getWindowHandle();
TargetLocator aLocator = aDriver.switchTo();
aLocator.window(currentWindowHandle);
Point p = getPoint(xStr, yStr);
Window aWindow = aDriver.manage().window();
aWindow.setPosition(p);
}
private Point getPoint(String xStr, String yStr)
{
int x = Integer.valueOf(xStr);
int y = Integer.valueOf(yStr);
return new Point(x, y);
}
Doesn't just maximising the browser's window suffice to control position? On the topic of downloading files: see my remark in #300
Maximizing the Firefox browser has odd effects on RHEL 7.4 with Xvfb headless display. setPosition() is supported in Selenium, and does the trick for my automated Unix testing.
I don't mind adding a method to postion the window, although I would put most of the logic in a new method in SeleniumHelper. Can you make a PR for it?
PR #307 has been submitted. All the logic is in SeleniumHelper:
https://github.com/fhoeben/hsac-fitnesse-fixtures/pull/307