Since the version of Selenium has been raised, I will write in detail for beginners
windows10 64bit google chrome(80.0.3987.106) eclipse (Version: 2019-12 (4.14.0))
First, download the zip file from this site. https://selenium.dev/downloads/ If you go down, you will reach here 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. When unzipped, the contents were quite different from the old ver
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. 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. We have everything you need here.
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
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)
After opening it, go to the "Library" tab. Click "Classpath" and select "Add jar" 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 Apply and close. This completes the settings for the jar file and so on!
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 ...
https://qiita.com/tsukakei/items/41bc7f3827407f8f37e8
Recommended Posts