0% found this document useful (0 votes)
118 views5 pages

Lab5Report PDF

1) The document describes a laboratory work on setting up a Selenium project using IntelliJ IDEA, Maven, and performing an automation test on the 9gag website. 2) The task was to open 9gag.com, search for "computer", and check that the 9gag header is displayed. 3) The project was set up with IntelliJ IDEA, Maven dependencies including Selenium were added, and a test was written to perform the specified task and assert the header is displayed. The test passed successfully.

Uploaded by

Vasilica Boaghi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
118 views5 pages

Lab5Report PDF

1) The document describes a laboratory work on setting up a Selenium project using IntelliJ IDEA, Maven, and performing an automation test on the 9gag website. 2) The task was to open 9gag.com, search for "computer", and check that the 9gag header is displayed. 3) The project was set up with IntelliJ IDEA, Maven dependencies including Selenium were added, and a test was written to perform the specified task and assert the header is displayed. The test passed successfully.

Uploaded by

Vasilica Boaghi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Technical University of the Moldova

Software Engeneering and Automation Department

Software Testing
Laboratory work nr.5

Theme: Introduction to automation

Report

Done By: Verified by:


Ion Dodon Mihai Lungu

Chisinau 2020
Laboratory scope: The spoce of this laboratory work is to understant how
to setup a selenium project using IntelijIdea, maven and how to use it for
automation testing.

Task: Variant 8: Open 9gag.com. Search for computer. Check that 9gag
header is displayed

Java IDE for Professional Developers – IntelliJ IDEA - IntelliJ IDEA is an


integrated development environment written in Java for developing
computer software. It is developed by JetBrains, and is available as an
Apache 2 Licensed community edition, and in a proprietary commercial
edition. Both can be used for commercial development.

Apache Maven - Maven is a build automation tool used primarily for Java
projects. Maven can also be used to build and manage projects written in
C#, Ruby, Scala, and other languages. The Maven project is hosted by the
Apache Software Foundation, where it was formerly part of the Jakarta
Project.

Selenium - Selenium is a portable framework for testing web applications.


Selenium provides a playback tool for authoring functional tests without
the need to learn a test scripting language (Selenium IDE). It also provides
a test domain-specific language (Selenese) to write tests in a number of
popular programming languages,
including C#, Groovy, Java, Perl, PHP, Python, Ruby and Scala. The tests
can then run against most modern web browsers. Selenium runs
on Windows, Linux, and macOS. It is open-source software released under
the Apache License 2.0.

How the goal was achieved:


1. First of all we have to setup the tools: InteliJIdea, a maven project and
prepare Selenium dependencies.
pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

2
<groupId>com.utm</groupId>
<artifactId>Selenium</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<maven.compiler.source>1.10</maven.compiler.source>
<maven.compiler.target>1.10</maven.compiler.target>
</properties>

<dependencies>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>htmlunit-driver</artifactId>
<version>2.23.2</version>
</dependency>
</dependencies>

</project>

2. After the project is prepared we we can create tests and in these tests we
can manipulate the web browser as we want. In this case we will enter
9gag.com, then will search “computer” and then will check if the header is
present.
public class ChromeDriverTest {

private WebDriver driver;

@Before
public void prepare() {
final String chromedriverPath = "/home/ion/Documents/UTM/QA (CS)/git/QA/Selenium/chromedriver";
final String testUrl = "https://9gag.com/";
System.setProperty("webdriver.chrome.driver", chromedriverPath);
driver = new ChromeDriver();
driver.manage().window().maximize();
driver.get(testUrl);
}

@Test
public void testTitle() throws IOException {
WebElement searchIcon = driver.findElement(By.xpath("//*[@id=\"top-nav\"]/div/div/div[1]/a[2]"));
3
searchIcon.click();

WebElement searchInput = driver.findElement(By.xpath("//*[@id=\"top-nav\"]/div/div/div[1]/div/form/div[1]/


input"));
searchInput.sendKeys("computer");
searchInput.sendKeys(Keys.ENTER);

boolean headerIsDisplayed = driver.findElement(By.xpath("//*[@id=\"top-nav\"]")).isDisplayed();

assertTrue("Header is not displayed!", headerIsDisplayed);


}

@After
public void teardown() {
driver.quit();
}
}
3. Then we run the program with the following command: mvn clean test.
This command will show the success/failure tests at the end.

mvn clean test result:


-------------------------------------------------------
TESTS
-------------------------------------------------------
Running ChromeDriverTest
Starting ChromeDriver 86.0.4240.22
(398b0743353ff36fb1b82468f63a3a93b4e2e89e-refs/branch-heads/4240@
{#378}) on port 27005
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for
suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
Nov 08, 2020 11:03:15 PM
org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 6.195 sec

Results :

Tests run: 1, Failures: 0, Errors: 0, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
4
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.993 s
[INFO] Finished at: 2020-11-08T23:03:19+02:00
[INFO] ------------------------------------------------------------------------

GitHub Link to the project:


https://github.com/iondodon/QA/tree/main/Selenium

Conclusion: After working on this laboratory wotk I have understood how


to prepare a Selenium project with maven and InteliJ IDE. I have
understood now to perform basic actions with the help of selenium. I also
integrated junit to have some tools like assetTrue(), when I want to validate
somethng.

Webography:
https://www.jetbrains.com/idea/download/#section=windows
https://www.guru99.com/intellij-selenium-
webdriver.html#:~:text=Step%203)%20Now%20You
%20need,4)%20Select%20all%20the%20selenium%20.

You might also like