hsac-fitnesse-fixtures icon indicating copy to clipboard operation
hsac-fitnesse-fixtures copied to clipboard

Need to set browser window position.

Open violinner opened this issue 5 years ago • 4 comments

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);
}

violinner avatar Feb 05 '20 14:02 violinner

Doesn't just maximising the browser's window suffice to control position? On the topic of downloading files: see my remark in #300

fhoeben avatar Feb 05 '20 20:02 fhoeben

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.

violinner avatar Feb 05 '20 21:02 violinner

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?

fhoeben avatar Feb 06 '20 07:02 fhoeben

PR #307 has been submitted. All the logic is in SeleniumHelper:

https://github.com/fhoeben/hsac-fitnesse-fixtures/pull/307

violinner avatar Feb 13 '20 21:02 violinner