Try running Selenuim 3.141.59 in eclipse (java)

Since the version of Selenium has been raised, I will write in detail for beginners

environment

windows10 64bit google chrome(80.0.3987.106) eclipse (Version: 2019-12 (4.14.0))

Download Selenium

First, download the zip file from this site. https://selenium.dev/downloads/ If you go down, you will reach here selenium.png Download the one in the target language. Click the download button to download the zip file. Save it somewhere and unzip the zip. When defrosted, the contents look like this. zip解凍.png When unzipped, the contents were quite different from the old ver

Download chrome driver

Download WebDriver for the next browser to test I use Google Chrome so go here. https://sites.google.com/a/chromium.org/chromedriver/downloads If you look inside the site, you can see the chrome version. Select and click the same version as the current chrome Click to jump here. chromium.png There is no 64-bit version of windows, so download the 32-bit one. This is also a zip, so unzip it. Make sure that only one file is included when you unzip it. chromiumExe.png We have everything you need here.

Run with eclipse

Let's create a project with eclipse and run it. Create a new project by selecting Workspace. Create "lib", "exe" folders under the project

"lib" -All the contents of the unzipped "lib" folder -"Client-combined-3.141.59-sources.jar" -"Client-combined-3.141.59.jar"

"exe" ・ Chomredriver.exe Is placed by import.

When placed, it looks like this 配置.png

Pass the build path

Now, add the added jar to the build path. Let's open the build path configuration (Right-click on the project-> Build Path-> Build Build Path) image.png

After opening it, go to the "Library" tab. Click "Classpath" and select "Add jar" image.png What you add is the one you just added to the "lib" folder. (You can select at once by shift + left click) When added, it looks like this image.png Apply and close. This completes the settings for the jar file and so on!

Create a file to execute

Create a file to execute next. Create a new class in the "src" folder. The class name can be anything. For the time being, the sample looks like this

Sample.java


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

public class Sample {

	public static void main(String[] args) throws InterruptedException {
		//TODO auto-generated method stub
	      // Optional, if not specified, WebDriver will search your path for chromedriver.
	      System.setProperty("webdriver.chrome.driver", "./exe/chromedriver.exe");

	      WebDriver driver = new ChromeDriver();
	      driver.get("http://www.google.com/xhtml");
	      Thread.sleep(5000);  // Let the user actually see something!
	      WebElement searchBox = driver.findElement(By.name("q"));
	      searchBox.sendKeys("ChromeDriver");
	      searchBox.submit();
	      Thread.sleep(5000);  // Let the user actually see something!
	      driver.quit();
	}

}

You can check the operation by running it in a java application that's all.

I just pulled the reference one If you think that the contents of the Selenium zip file are too different for beginners like me who were surprised ...

reference

https://qiita.com/tsukakei/items/41bc7f3827407f8f37e8

Recommended Posts

Try running Selenuim 3.141.59 in eclipse (java)
Try running AWS X-Ray in Java
Try using RocksDB in Java
Try calling JavaScript in Java
Try developing Spresense in Java (1)
Try functional type in Java! ①
Null-safe program in Java (Eclipse)
First Java development in Eclipse
Try implementing Android Hilt in Java
Try implementing GraphQL server in Java
Try running ruby-net-nntp and tmail in 2020
Try an If expression in Java
Hello World in java in eclipse now
Try to implement Yubaba in Java
Try Eclipse 4.7 Oxygen New 30+ / Java 10 var!
JPA (Java Persistence API) in Eclipse
Try to implement n-ary addition in Java
Try using the Stream API in Java
Try using JSON format API in Java
Try calling the CORBA service in Java 11+
[Java] Set AdoptOpen JDK in STS (Eclipse)
Play Framework 2.6 (Java) environment construction in Eclipse
Try running a Kubernetes Job from Java
Try making a calculator app in Java
Partization in Java
Try Java 8 Stream
Changes in Java 11
Rock-paper-scissors in Java
MVC in Eclipse.
Pi in Java
Roughly try Java 9
FizzBuzz in Java
Technology for reading Java source code in Eclipse
[Java] API creation using Jerjey (Jax-rs) in eclipse
Try to create a bulletin board in Java
Pleiades Eclipse 2020-03 release ~ Java 14 Let's try new features!
Second decoction: Try an If expression in Java
Try using GCP's Cloud Vision API in Java
Try using Sourcetrail (macOS version) in Java code
Try using the COTOHA API parsing in Java
[java] sort in list
Read JSON in Java
Interpreter implementation in Java
Make Blackjack in Java
Try calling synchronized methods from multiple threads in Java
Rock-paper-scissors app in Java
Java (eclipse) installation procedure
Eclipse ~ Java project creation ~
NVL-ish guy in Java
Combine arrays in Java
"Hello World" in Java
Callable Interface in Java
It's late! Try implementing Android Notification in Java (Beginner)
Comments in Java source
Azure functions in java
Try LetCode in Ruby-TwoSum
Format XML in Java
To debug in eclipse
Boyer-Moore implementation in Java
Hello World in Java
Use OpenCV in Java