java 版 selenium 自动化操作 chrome
发布日期:2021-10-07 04:43:08 浏览次数:10 分类:技术文章

本文共 746 字,大约阅读时间需要 2 分钟。

 一、selenium 在java中的使用

System.setProperty("webdriver.chrome.driver", local);//加载chrome 位置

        ChromeOptions options = new ChromeOptions();
        options.addArguments("window-size=1280,728");   //设置窗口大小
//        String user_data = System.getProperty("user.dir") + "\\src\\com\\selenium\\chrome_data";
//        options.addArguments("user-data-dir=" + user_data); 
//        options.addArguments("headless=true"); //无头
        DesiredCapabilities cap = DesiredCapabilities.chrome();
        cap.setCapability(ChromeOptions.CAPABILITY, options);
        cap.setCapability("goog:" + ChromeOptions.CAPABILITY, options);
        WebDriver webDriver = new ChromeDriver(cap);
        RemoteWebDriver  rdriver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"),cap);//远程方式,想用多线程需要这么写
        rdriver.get("http://pan.baidu.com");

 

 

 

 

转载地址:https://blog.csdn.net/meandmyself/article/details/88992396 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:python 网络数据包处理和嗅探工具Scapy 学习笔记(一)
下一篇:安装python3版的keystone 连接mysql 8.0

发表评论

最新留言

初次前来,多多关照!
[***.217.46.12]2024年04月13日 05时24分27秒