最新消息: USBMI致力于为网友们分享Windows、安卓、IOS等主流手机系统相关的资讯以及评测、同时提供相关教程、应用、软件下载等服务。

selenium3.0打开浏览器代码(谷歌、火狐、safari)

业界 admin 2浏览 0评论
    static WebDriver driver;

    // 打开浏览器
    static void openBrowser(String browserName) {
        try {
            switch (browserName) {
                case "chrome":
                    System.setProperty("webdriver.chrome.driver", Constants.Path_chrome);
                    driver = new ChromeDriver();
//                    driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); //隐式等待
                    System.out.println("打开谷歌浏览器");
                    break;
                case "firefox":
                    if (FileTools.getPropertyOsName().contains("Mac")) {
                        System.setProperty("webdriver.firefox.bin", Constants.Path_firefox);
                    } else if (FileTools.getPropertyOsName().contains("Windows")) {
                        System.setProperty("webdriver.gecko.driver", Constants.Path_firefox);
                    }
                    driver = new Fi
    static WebDriver driver;

    // 打开浏览器
    static void openBrowser(String browserName) {
        try {
            switch (browserName) {
                case "chrome":
                    System.setProperty("webdriver.chrome.driver", Constants.Path_chrome);
                    driver = new ChromeDriver();
//                    driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); //隐式等待
                    System.out.println("打开谷歌浏览器");
                    break;
                case "firefox":
                    if (FileTools.getPropertyOsName().contains("Mac")) {
                        System.setProperty("webdriver.firefox.bin", Constants.Path_firefox);
                    } else if (FileTools.getPropertyOsName().contains("Windows")) {
                        System.setProperty("webdriver.gecko.driver", Constants.Path_firefox);
                    }
                    driver = new Fi
发布评论

评论列表 (0)

  1. 暂无评论