LambdaTest Community

Find answers, support, and inspiration from other users

Questions
LambdaTest Community
Answered

How do I run parallel tests with Selenium testing framework Selenide?

I want some information regarding running parallel tests with Selenium testing framework Selenide. Can anyone please guide me onto that.

Up Vote Down Vote 0 Votes
Posted 4 months ago

Answers


Selenium Testing With Selenide: Setting Up The Environment

The pre-requisites are JDK 1.8.0 and Intellij.

For installing Java, minimum JDK 8 is required, to download in official site click here.

After download, installation is very simple and self-explanatory to complete.

After installation is complete, you would have to setup the classpath so that the program understand where the java is located in your machine

This can be done in windows operating system by searching for “Environment Variables” and selecting “Edit System Environment Variables”. Create JAVA_HOME in system variable and PATH as mentioned in the below snapshot.

Create JAVA_HOME in System variable and update the value where the Java is located in your machine.

Now, we need to edit the Path system variable and add JAVA_HOME in it so that all run time programs are able to detect Java in your machine. Make sure you append the value after adding a semicolon.

To verify, if JDK is properly installed or not. You need to supply the below command: java -version

Kudos! You just installed JDK successfully on your machine.

Selenium Testing With Selenide – Download IntelliJ And Setting Up Maven project

There are multiple IDE’s available in the market. In this article, I recommend using IntelliJ for Selenium testing with Selenide. IntelliJ is a free, open-source Java IDE(Integrated Development Environment) for developing Java, Kotlin based software programming. This tool has Community and Ultimate version, community version of IntelliJ can be downloaded from here.

After download Intellij, the installation part is pretty much easy, just follow with instruction and keep going with default parameter and complete it.

Open Intellij and select “Create New Project” from Dashboard window.

For this Article, I would prefer to use a “Maven” project. Select the particular Java version that we installed and click on Next with Default parameters.

Enter values in necessary fields like GroupID, ArtifactID and keep it as default version.

Leave the project name and select where your project is to be located.

The created Selenide project is displayed in IntelliJ as mentioned below.

Add Selenide Maven Dependency as mentioned below:

<dependencies>

<!-- https://[mvnrepository.com/artifact/com.codeborne/selenide](mvnrepository.com/artifact/com.codeborne/selenide) -->

<dependency>

<groupId>com.codeborne</groupId>

<artifactId>selenide</artifactId>

<version>5.1.0</version>

</dependency>

</dependencies>

Feel free to add the required transient dependencies in your class path. As I previously mentioned, selenide library supports TestNG, JUnit frameworks.

Selenium Testing With Selenide- Sample Code(Self Explanatory)

package selenidesamples;

import [http://org.openqa.selenium.By](http://org.openqa.selenium.by/);

import org.testng.Assert;

import org.testng.annotations.Test;

import static com.codeborne.selenide.CollectionCondition.texts;

import static com.codeborne.selenide.Condition.text;

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

public class LambdaSampleParallelTestAutomation extends BaseConfig_LambdaTest {

/**

* Author: Muthuraja R

* Description: Validate Error message in Registration Page and capture one of error throws correct or not

*/

@Test

public void verifyStartTestingButton() {

//Launch Lambdatest page

open("[https://www.lambdatest.com/](https://www.lambdatest.com/)");

//use CSS Selector to find element and click for navigating register page

$(".nav>li.login>a").click();

//Verifying Page title using Selenide reusable method

Assert.assertEquals("Sign up for free | Cross Browser Testing Tool | LambdaTest - LambdaTest", title());

//Verifying text "Sign up"

$(".signup-titel").shouldHave(text("SIGN UP"));

//Feeding value to the text using .val

//Feeding value to the text using sendkeys

$(http://By.name("organization_name")).val("org");

$(http://By.name("name")).sendKeys("Name");

$(http://By.name("email")).sendKeys("test@gmail.com");

$(http://By.name("password")).sendKeys("test1234");

//using shortcut to signup instead of clicking button

$(http://By.name("phone")).val("13452").pressEnter();

//Capturing actual results and verifying with expected one using collections

$$(".error-mass").shouldHave(

texts("This email is already registered",

"Please enter a valid Phone number",

"To proceed further you must agree to our Terms of Service and Privacy Policy"));

}

}

In the above example:

  • Login to LambdaTest Page.
  • Click on Register button.
  • Enter invalid value in org, fullname, work email, desired password and phone to target on mandatory fields to make sure it returns error.
  • Finally capture all errors throws in the page using collections.
Up Vote Down Vote 0 Votes
Posted 3 months ago