Lab5Report PDF
Lab5Report PDF
Software Testing
Laboratory work nr.5
Report
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
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.
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 {
@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();
@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.
Results :
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
4
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.993 s
[INFO] Finished at: 2020-11-08T23:03:19+02:00
[INFO] ------------------------------------------------------------------------
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.