LoginSignup
2
1

More than 5 years have passed since last update.

Selenium のサンプル (Java)

Last updated at Posted at 2018-09-20

Selenium のサンプルです。

ex01.java
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class ex01 {

    public static void main(String[] args) {
        WebDriver driver = new FirefoxDriver();
        driver.get("https://ekzemplaro.org/storytelling/");
    try {
        System.out.println("5秒停止します");
        Thread.sleep(5000);
        System.out.println("一時停止を解除しました。");
    } catch(InterruptedException e){
        e.printStackTrace();
        }
        driver.quit();
    }
}
Makefile
ex01.class: ex01.java
    javac ex01.java -cp ./client-combined-3.14.0.jar 
clean:
    rm -f ex01.class

コンパイル

$ make
javac ex01.java -cp ./client-combined-3.14.0.jar

実行方法

export CLASSPATH=.:./client-combined-3.14.0.jar:./guava-26.0-jre.jar:./okhttp-3.11.0.jar:./okio-2.0.0.jar:./kotlin-stdlib-1.2.60.jar:./commons-exec-1.3.jar
#
java ex01

実行時に次の jar が必要になります。

client-combined-3.14.0.jar
guava-26.0-jre.jar
okhttp-3.11.0.jar
okio-2.0.0.jar
kotlin-stdlib-1.2.60.jar
commons-exec-1.3.jar

使った Java の環境です。

$ javac --version
javac 10.0.2
$ java --version
openjdk 10.0.2 2018-07-17
OpenJDK Runtime Environment (build 10.0.2+13)
OpenJDK 64-Bit Server VM (build 10.0.2+13, mixed mode)
2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1