java selenium手动最大化chrome浏览器的方法

package my_automation;

import java.awt.Dimension;

import org.openqa.selenium.Capabilities;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.remote.RemoteWebDriver;

import com.sun.javafx.scene.paint.GradientUtils.Point;
import com.sun.javafx.tk.Toolkit;

public class open_browser_01 {

    public static void main(String[] args) throws InterruptedException {
        //火狐启动设置:
//        System.setProperty("webdriver.firefox.bin", "E:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe");
//        WebDriver driver = new FirefoxDriver();
        
        // IE浏览器设置:
        //WebDriver driver = new InternetExplorerDriver();
        
        //谷歌,浏览器设置1:
        WebDriver driver = new ChromeDriver();
//        final JavascriptExecutor js = (JavascriptExecutor) driver;
//        js.executeScript("window.open('','testwindow','width=1600,height=900')");
//        driver.switchTo().window("testwindow");
//        
//        js.executeScript("window.moveTo(0,0);");
//        js.executeScript("window.resizeTo(600,600);");
        
        
        ////谷歌,浏览器设置2:
//        ChromeOptions options = new ChromeOptions();
//        options.addArguments("--start-maximized");
//        RemoteWebDriver driver = new ChromeDriver(options);
        
        driver.manage().window().maximize();
        driver.get("https://www.baidu.com");
        Thread.sleep(5000);
        driver.quit();

    }

}

 

posted @ 2017-12-12 14:53  热爱技术的小牛  阅读(2347)  评论(0编辑  收藏  举报
热爱技术的小牛