Adding Masala to the Selenide Test Automation Framework with Allure

Adding Masala to the Selenide Test Automation Framework with Allure

Selenide is a ++ version of Selenium WebDriver, which we have looked upon in a previous article. Selenide was developed by a group of Russian developers which add more features than the traditional Selenium WebDriver. It handles Ajax and Angular support, ease of learning commands and also it does not need to have Selenium standard server running when executing the commands in the browser.

Thanks to the inventors they have introduced the Selenium wrapper tool. Now its time for us to integrate this tool with the framework components. Here we will add Masala to the tool and try to integrate to the a test automation framework. This is how we integrated the tried and tested components. This is one of the first articles to introduce Allure to Selenide.

First lets add Allure dependencies and Selenide dependency to our Maven test automation framework.

<project xmlns="https://maven.apache.org/POM/4.0.0" xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<properties>
    <aspectj.version>1.8.10</aspectj.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
  <modelVersion>4.0.0</modelVersion>
  <groupId>SelenideWithAssure</groupId>
  <artifactId>SelenideWithAssure1.0</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <dependencies>
  <dependency>
    <groupId>io.qameta.allure</groupId>
    <artifactId>allure-testng</artifactId>
    <version>2.0-BETA19</version>
</dependency>
<dependency>
    <groupId>com.codeborne</groupId>
    <artifactId>selenide</artifactId>
    <version>4.8</version>
</dependency>
  </dependencies>
     <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.20</version>
                <configuration>
                    <suiteXmlFiles>
                        <suiteXmlFile>TestNG.xml</suiteXmlFile>
                    </suiteXmlFiles>
                    <argLine>
                        -javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar"
                    </argLine>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.aspectj</groupId>
                        <artifactId>aspectjweaver</artifactId>
                        <version>${aspectj.version}</version>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>
    </build>
</project>
 
  

Next lets create the automation test case with a TestNG class. Lets also import the libraries needed for Allure and Selenide.

package SelenidTest;
import static com.codeborne.selenide.Selenide.*;
import static com.codeborne.selenide.Condition.*;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.Assert;
import org.testng.annotations.*;
import org.openqa.selenium.By;
import io.qameta.allure.Description;
import io.qameta.allure.Severity;
import io.qameta.allure.SeverityLevel;


import com.codeborne.selenide.WebDriverRunner;


public class SelenideGoogleTest {
	WebDriver driver = new ChromeDriver();
	@Severity(SeverityLevel.NORMAL)
	@Test (description="This test will search Sri Lanka from the google search and navigate to wikipedia page...")
	@Description ("Selenide Allure Report Integration")
	public void searchGoogle()
	{
	/// WebDriver chrome = null;
	WebDriverRunner.setWebDriver(driver);
	 open("https://www.google.lk");
	 $(By.id("lst-ib")).setValue("Sri Lanka");
	 $(By.className("lsb")).click();
	 $(By.linkText("Sri Lanka - Wikipedia")).click();
	 String titlePage = title();
	 Assert.assertEquals(titlePage, "Sri Lanka - Wikipedia", "Titles are matching");
	 close();
	}	
}

 
  

Next lets run the test scenario and upon success generate the Allure reports from the created Jason files (from the script execution).

To generate and start the Jetty server use the following command.

allure serve C:\Users\kushan\workspace1\SelenideWithAssure1.0\allure-results

Whollaa..we have the Allure dashboard started with the report we have just generated....We intergrated Allure with Selenide.


要查看或添加评论,请登录

Kushan Shalindra Amarasiri的更多文章

社区洞察

其他会员也浏览了