Selenium x Java

I tried using Selenium in Java

What is Selenium

In short, it is a library for automatically executing web applications and parsing HTML (web scraping). Libraries are available in multiple languages such as python, node.js, Java, and PHP, and can be easily implemented.

Target

Introducing Java x Selenium, until "Start Chrome → Open Google Search".

Architect

language Java( ver.11 )
build Maven
browser Google Chrome
IDE IntelliJ

procedure

Premise Java x Maven application environment has been built.

Preparation

  1. Add and load the Selenium library that depends on pom.
<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-java</artifactId>
    <version>3.12.0</version>
</dependency>
  1. Download the Chrome driver to run on Chrome. This allows Chrome to run it. If you want to do it with another browser, you can download the driver for each browser.

Download chrome driver http://chromedriver.chromium.org/downloads

Executing sample code

"Start Chrome → Open Google Search"

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class MainApplication {

    public static void main(String[] args){
        final String PATH = "* Chrome Driver path";
        System.setProperty("webdriver.chrome.driver", PATH);
        WebDriver driver = new ChromeDriver();

        final String URL = "http://www.google.com";
        //URL transition
        driver.get(URL);
    }
}

Run the application and if you see a Google search like below Success: clap: スクリーンショット 2019-11-24 10.48.38.png

Recommended Posts

Selenium x Java
Selenium sample (Java)
Java
Java
Selenium Sample Reservation Form (Java)
Selenium
AWS SDK for Java 1.11.x and 2.x
[For beginners] Run Selenium in Java
[ev3 x Java] Intelligent block button
Use Chrome Headless from Selenium / Java
Follow the link with Selenium (Java)
Java + OpenCV 3.X in IntelliJ IDEA
[ev3 x Java] Single motor control
Java learning (0)
Studying Java ―― 3
[Java] array
[Java] Annotation
Batch startup monitoring (Java x PushGateway x Prometheus)
[Java] Module
Java array
Java tips, tips
Java methods
Java method
java (constructor)
Java array
[Java] ArrayDeque
java (override)
java (method)
Java Day 2018
[Processing x Java] Construction of development environment
java (array)
Java static
Java serialization
JAVA paid
Java (set)
java shellsort
Studying Java -5
java reflexes
java (interface)
Java memorandum
☾ Java / Collection
Studying Java ―― 1
[Java] Array
[Java] Polymorphism
Studying Java # 0
Java review
java framework
Java features
Java features
Try Selenium
java beginner 3
Java memo
java (encapsulation)
Java inheritance
[Java] Overload
Java basics
Decompile Java
[Java] Annotation
java notes
java beginner
Java (add2)