Lets start test automation in Java with FluentLenium
Kushan Shalindra Amarasiri
Director Quality Engineering at Social Catfish
There are so many tools available in the market and out of these most of them are free and open source tools. Selenium being the top ranked test automation tool, there are several other test automation libraries and wrappers built around.
Today in this article I'm going to show how we can start test automation with a Java Selenium wrapper called FluentLenium.
To start lets add the following dependency for the maven project.
<dependency>
<groupId>org.fluentlenium</groupId>
<artifactId>fluentlenium-core</artifactId>
<version>3.4.1</version>
</dependency>
Next lets create a JUnit test and add the following code and execute.
package FluPkg;
import static org.assertj.core.api.Assertions.assertThat;
import org.fluentlenium.adapter.junit.FluentTest;
import org.junit.Test;
public class FluBasic extends FluentTest {
@Test
public void google_search() {
goTo("https://www.google.lk");
$("#lst-ib").fill().with("Selenium");
$("#tsf > div.tsf-p > div.jsb > center > input[type=\"submit\"]:nth-child(1)").submit();
$("#rso > div:nth-child(1) > div > div:nth-child(1) > div > div > div.r > a").click();
assertThat(window().title()).contains("Selenium - Web Browser Automation");
}
}
The test will get executed in the browser.
Senior Advisory Consultant at IBM (MBA,MCom)
5 年Hey