I am using java + selenium webdriver for webautomaiton. For safari browser 10.1 version, I need the browser to be full screen before test started.However
driver.manage().window().maximize();
does not work
I tried few options but no luck.
1. seems no option available for doing something like which would write in the plist file of /Library/Preferences folder of mac
defaults write com.apple.Safari
2
WebElement element = Wait.wait.until(visibilityOfElementLocated(By.cssSelector(".logo-large")));
element.sendKeys(Keys.CONTROL , Keys.COMMAND , "f");
element.sendKeys(Keys.CONTROL , Keys.COMMAND , "F");
Actions action = new Actions(driver);
action.keyDown(Keys.CONTROL).keyDown(Keys.COMMAND).sendKeys("F").perform();
action.keyDown(Keys.CONTROL).keyDown(Keys.COMMAND).sendKeys("f").perform();
Is there anyway I can do it using send keys, or write in the plist file or through javascript.
Try below :-
public static void maximizeScreen(WebDriver driver) {
java.awt.Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Point position = new Point(0, 0);
driver.manage().window().setPosition(position);
Dimension maximizedScreenSize =
new Dimension((int) screenSize.getWidth(), (int) screenSize.getHeight());
driver.manage().window().setSize(maximizedScreenSize);
}
Hore it will help you
Take a look here ( Native Fullscreen JavaScript API ): http://johndyer.name/native-fullscreen-javascript-api-plus-jquery-plugin/
您必须更新safari浏览器,使用Safari 11+版本更新浏览器,然后才能使用以下代码将其最大化:
driver.manage().window().maximize();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.