Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need to set browser window position. #299

Open
violinner opened this issue Feb 5, 2020 · 4 comments
Open

Need to set browser window position. #299

violinner opened this issue Feb 5, 2020 · 4 comments

Comments

@violinner
Copy link

violinner commented Feb 5, 2020

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);
}
@fhoeben
Copy link
Owner

fhoeben commented Feb 5, 2020

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

@violinner
Copy link
Author

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.

@fhoeben
Copy link
Owner

fhoeben commented Feb 6, 2020

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?

@violinner
Copy link
Author

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

#307

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants