zoukankan      html  css  js  c++  java
  • selenium phantomjs java无界面浏览器环境搭建

    java selenium搭建无界面浏览器

    1.http://phantomjs.org/

    下载windows版phantomjs

    2.解压后bin目录下会有exe文件

    3.测试代码:

    package se;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.firefox.FirefoxDriver;
    import org.openqa.selenium.phantomjs.PhantomJSDriver;
    public class test {
    
        public static void main(String[] args) {
            // TODO Auto-generated method stub
        //    System.setProperty("webdriver.gecko.driver", "C:\Program Files (x86)\Mozilla Firefox\geckodriver.exe");
            System.setProperty("phantomjs.binary.path", "C:\phantomjs-2.1.1-windows\bin\phantomjs.exe");
        //    WebDriver driver = new FirefoxDriver();
            WebDriver driver = new PhantomJSDriver();
            driver.get("http://www.baidu.com");
            System.out.println(driver.getCurrentUrl());
            
    
        }
    
    }

    4.url成功打印

    需要的添加的jar包及工具:我这里使用maven来构建项目,添加依赖如下:

    <dependency>
      <groupId>org.seleniumhq.selenium</groupId>
      <artifactId>selenium-java</artifactId>
      <version>3.2.0</version>
    </dependency>  
  • 相关阅读:
    华为软件开发云评测
    个人技术博客(α)
    结对第二次作业
    结对第一次作业----部门通
    数独设计
    2017软件工程实践第一次作业
    Alpha冲刺博客集
    个人作业——软件工程实践总结作业
    用户使用调查报告
    总结随笔(Beta)
  • 原文地址:https://www.cnblogs.com/wpcnblog/p/8445076.html
Copyright © 2011-2022 走看看