[JAVA] Try to create a browser automatic operation environment using Selenide in 5 minutes


This article is M3 Career Advent Calendar 2019 Day 13 article. In this article, we will use Selenide, which is a wrapper of Selenium Web Driver, to quickly try out the browser operation.

Target audience

--People who want to try the automatic operation of the browser for the time being --People who want to write UI tests in Java --People who want to create tools for browser operation

Development environment preparation

Let's start by preparing the development environment. Use eclispe for the IDE. Download Java Full Edition from https://mergedoc.osdn.jp/ and unzip it to any location. eclipse.png

After unzipping, start eclipse.exe.

Preparing selenide

Next, create a Gradle project. image.png

Once the project is created, add the following sentence to build.gradle.

testCompile 'com.codeborne:selenide:5.5.1'


This completes the environment preparation.


Since / [project name] /src/test/java/[project name] /LibraryTest.java was created when the Gradle project was finally created, comment out the original process and rewrite it as follows.

 * This Java source file was generated by the Gradle 'init' task.
package selenideSample;

import static com.codeborne.selenide.Selenide.*;

import org.junit.Test;

public class LibraryTest {
    @Test public void testSomeLibraryMethod() {
//        Library classUnderTest = new Library();
//        assertTrue("someLibraryMethod should return 'true'", classUnderTest.someLibraryMethod());

Well, it's finally time to run. Right-click on the LibraryTest.java file and run the JUnit test. image.png

If the execution is successful, you can see that a new chrome is started and the Yahoo screen is displayed. (The browser will close automatically after a certain period of time) image.png


The environment for realizing browser operation on the code has been easily created. This time, I only opened the specified URL, but it is also very convenient because I can write general browser operations such as inputting to a text box, selecting a pull-down, checking a check box, etc. in code. In my work, I use it when creating a large amount of test data from a browser. The Official Reference of selenide is also substantial, so we hope you will take advantage of it.


https://selenide.org/quick-start.html https://qiita.com/tatesuke/items/589e30ab9b3dc7037e26

Recommended Posts

Try to create a browser automatic operation environment using Selenide in 5 minutes
How to create a Java environment in just 3 seconds
Try to build a Java development environment using Docker
Create a MySQL test environment (+ millions of test data) in 5 minutes
Create a database in a production environment
Try to create a server-client app
Build a browser test environment using Capybara in the Docker development environment
Create a web environment quickly using Docker
How to create a query using variables in GraphQL [Using Ruby on Rails]
Try to display a slightly rich Webview in Swift UI using UIViewRepresentable
[Rails] How to create a graph using lazy_high_charts
A memo to simply create a form using only HTML and CSS in Rails 6
How to create a theme in Liferay 7 / DXP
How to easily create a pull-down in Rails
Try to make a music player using Basic Player
Docker command to create Rails project with a single blow in environment without Ruby
[Introduction] Try to create a Ruby on Rails application
A memorandum when trying to create a GUI using JavaFX
I tried to create a Clova skill in Java
How to create a data URI (base64) in Java
How to display a browser preview in VS Code
How to convert A to a and a to A using AND and OR in Java
Try to solve a restricted FizzBuzz problem in Java
I tried to create a java8 development environment with Chocolatey
I want to find a relative path in a situation using Path
How to create a placeholder part to use in the IN clause
Create a method to return the tax rate in Java
Create a tomcat project using Eclipse Pleiades All in One
I want to create a Parquet file even in Ruby
How to create a service builder portlet in Liferay 7 / DXP
I tried to create a padrino development environment with Docker
[Enum_help] Use enum_help to create a select box displayed in Japanese!
Try using RocksDB in Java
Create a fortune using Ruby
Try using gRPC in Ruby
How to create a method
How to create a jar file or war file using the jar command
I tried to create a simple map app in Android Studio
[Rails] How to execute "rails db: create" etc. in production environment EC2
A story of frustration trying to create a penetration environment on Ubuntu 20.04
[Rails 6] How to create a dynamic form input screen using cocoon
[Implementation procedure] Create a user authentication function using sorcery in Rails
How to create a new Gradle + Java + Jar project in Intellij 2016.03
I tried to create a Spring MVC development environment on Mac
Easy way to create a mapping class when using the API
Install Rails in the development environment and create a new application