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

static WebDriver driver; 打开浏览器static void openBrowser(String browserName) {try {switch (browserName) {case "chrom

    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

发布者:admin,转转请注明出处:http://www.yc00.com/web/1737921542a3997539.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信