Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete issue test #94

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions test/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
target
src/test/java/gmibank/runners
src/test/java/issueTracker/Runners
.idea
libraries
2 changes: 2 additions & 0 deletions test/issueTracker.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4" />
149 changes: 56 additions & 93 deletions test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,128 +5,105 @@
<modelVersion>4.0.0</modelVersion>

<groupId>org.example</groupId>
<artifactId>issuetracker</artifactId>
<artifactId>issueTracker</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>

<dependencies>
<!-- https://mvnrepository.com/artifact/org.postgresql/postgresql -->
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.14</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.rest-assured/rest-assured -->
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<version>4.3.0</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.testng/testng -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.1.0</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.itextpdf/itextpdf -->
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itextpdf</artifactId>
<version>5.4.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.github.bonigarcia/webdrivermanager -->
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>8.2.2.jre8</version>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>3.8.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->

<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.8</version>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
</dependency>

<!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-java -->
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>5.7.0</version>
</dependency>

<!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-junit -->
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>5.7.0</version>
<scope>test</scope>
</dependency>

<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-simple -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.30</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.19</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.github.bonigarcia/webdrivermanager -->
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>3.8.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>4.1.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.1.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.github.javafaker/javafaker -->
<dependency>
<groupId>com.github.javafaker</groupId>
<artifactId>javafaker</artifactId>
<version>1.0.2</version>
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itextpdf</artifactId>
<version>5.5.10</version>
</dependency>
<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox</artifactId>
<version>2.0.4</version>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<version>4.3.0</version>
<scope>test</scope>
</dependency>

</dependencies>



</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.0.0-M1</version>
<configuration>
<testFailureIgnore>true</testFailureIgnore>
<skipTests>false</skipTests>
<includes>
<include>**/Runners/*Runner*.java</include>
</includes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M1</version>
<configuration>
<parallel>classes</parallel>
<forkMode>perthread</forkMode>
<threadCount>2</threadCount>
<reuseForks>false</reuseForks>
<argLine>-Duser.language=en</argLine>
<argLine>-Xmx1024m</argLine>
<argLine>-XX:MaxPermSize=256m</argLine>
<argLine>-Dfile.encoding=UTF-8</argLine>
<useFile>false</useFile>
<includes>
<include>**/*CukesRunner.java</include>
<include>**/Runners/*Runner*.java</include>
</includes>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>
<plugin>
<groupId>net.masterthought</groupId>
<artifactId>maven-cucumber-reporting</artifactId>
<version>4.4.0</version>
<version>5.0.0</version>
<executions>
<execution>
<id>execution</id>
Expand All @@ -136,32 +113,18 @@
</goals>
<configuration>
<projectName>cucumber-jvm-example</projectName>
<!-- output directory for the generated report -->
<outputDirectory>${project.build.directory}</outputDirectory>
<!-- optional, defaults to outputDirectory if not specified -->
<inputDirectory>${project.build.directory}</inputDirectory>
<jsonFiles>
<!-- supports wildcard or name pattern -->
<param>**/cucumber.json</param>
</jsonFiles>
<classificationFiles>
<!-- supports wildcard or name pattern -->
<param>sample.properties</param>
<param>other.properties</param>
</classificationFiles>
<!--<parallelTesting>false</parallelTesting>-->
<param>**/json-reports/*.json</param>
</jsonFiles><classificationFiles>->
<param>sample.properties</param>
<param>other.properties</param>
</classificationFiles>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
</plugins>
</build>

Expand Down
13 changes: 13 additions & 0 deletions test/src/test/java/issueTracker/Pages/IssueListPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@ public IssueListPage() {
public WebElement text;
@FindBy(xpath = "//tbody//tr")
public List<WebElement> rows;
@FindBy(xpath = "//div[@class='info']")
public WebElement message;
@FindBy(id = "validationCustom01")
public WebElement titleUpdate;
@FindBy(xpath = "//button[@type='submit']")
public WebElement updateButton;
@FindBy(xpath = "//button[@class='btn btn-danger']")
public WebElement cancelButton;
@FindBy(id = "validationCustom02")
public WebElement descriptionUpdate;
@FindBy(id = "validationCustom03")
public WebElement labelsUpdate;

public static WebElement findingThead(String columnName) {
int columnNumber = 0;
Expand All @@ -33,4 +45,5 @@ public static WebElement findingThead(String columnName) {
WebElement thead = Driver.getDriver().findElement(By.xpath("//thead//th[" + columnNumber + "]"));
return thead;
}

}
8 changes: 3 additions & 5 deletions test/src/test/java/issueTracker/Runners/Runner.java
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
package issueTracker.Runners;

import io.cucumber.junit.Cucumber;
import io.cucumber.junit.CucumberOptions;
import org.junit.runner.RunWith;

@RunWith(Cucumber.class)
@CucumberOptions(strict = true,
@CucumberOptions(
plugin = {
"html:target/default-cucumber-reports",
"json:target/json-reports/cucumber.json",
"junit:target/xml-report/cucumber.xml"
},
//plugin = "html:target\\default-cucumber-reports",
features ="src/test/resources/features",
glue = "issueTracker/StepDefinitions",
tags = "@api",
tags = "@smokeTest" ,
dryRun = false
)
public class Runner {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
import io.restassured.http.ContentType;
import io.restassured.response.Response;
import issueTracker.Utilities.ConfigReader;

import static io.restassured.RestAssured.*;
import static io.restassured.RestAssured.given;

public class ApiStepDefs {
@Given("user gets all data from api")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import issueTracker.Utilities.ConfigReader;
import issueTracker.Utilities.Driver;
import issueTracker.Utilities.Pages;
import javafx.beans.value.WeakChangeListener;
import issueTracker.Utilities.ReusableMethods;
import org.junit.Assert;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
Expand All @@ -16,6 +16,7 @@

public class CreateIssueStepDefs {
Pages pages = new Pages();
ReusableMethods reusableMethods =new ReusableMethods();

@Given("user on the homepage")
public void user_on_the_homepage() {
Expand Down Expand Up @@ -53,16 +54,19 @@ public void user_clicks_on_create_new_issue_button() {
}
@Then("verify that issue list has {string}")
public void verify_that_issue_list_has(String title) {
reusableMethods.wait(2);
pages.homePage().issueListButton.click();

List<String> rowText= new ArrayList<>();
for (int i=0;i<pages.issueListPage().rows.size();i++){
rowText.add(pages.issueListPage().rows.get(i).getText());
System.out.println(pages.issueListPage().rows.get(i).getText());
//System.out.println(pages.issueListPage().rows.get(i).getText());
if(pages.issueListPage().rows.get(i).getText().equals(title)){
JavascriptExecutor js = (JavascriptExecutor)Driver.getDriver();
JavascriptExecutor js = (JavascriptExecutor) Driver.getDriver();
int row = i+1;
WebElement actualTitle = Driver.getDriver().findElement(By.xpath("//tbody//tr["+row+"]"));
js.executeScript("arguments[0].scrollIntoView(true);", actualTitle);
js.executeScript("arguments[0].setAttribute('style', 'background: yellow; border: 2px solid green;');", actualTitle);
System.out.println(i);
}
}
Assert.assertTrue("Creation failure", rowText.contains(title));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,63 @@
package issueTracker.StepDefinitions;

import io.cucumber.java.en.Given;
import io.cucumber.java.en.Then;
import issueTracker.Utilities.Driver;
import issueTracker.Utilities.Pages;
import issueTracker.Utilities.ReusableMethods;
import org.junit.Assert;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

public class DeleteIssueStepDefs {
int row;
Pages pages = new Pages();
@Given("user clicks on remove button")
public void user_clicks_on_remove_button() {
pages.homePage().removeButton.click();
ReusableMethods reusableMethods =new ReusableMethods();

@Given("user clicks on issue list button")
public void user_clicks_on_issue_list_button() {
pages.homePage().issueListButton.click();
}

@Given("user selects {string} to delete")
public void user_selects_to_delete(String title) {
reusableMethods.wait(2);
for (int i = 0; i < pages.issueListPage().rows.size(); i++) {
if (pages.issueListPage().rows.get(i).getText().equals(title)) {
JavascriptExecutor js = (JavascriptExecutor) Driver.getDriver();
row = i+1;
WebElement actualTitle = Driver.getDriver().findElement(By.xpath("//tbody//tr[" + row + "]"));
js.executeScript("arguments[0].scrollIntoView(true);", actualTitle);
reusableMethods.wait(2);
js.executeScript("arguments[0].setAttribute('style', 'background: yellow; border: 2px solid red;');", actualTitle);
}
}
}

@Given("user clicks on trash icon")
public void user_clicks_on_trash_icon() {
reusableMethods.wait(2);
String xpath = "(//tbody//tr["+ row + "]//td[3]//*[name()='svg']/*[name()='path'])[2]";
WebElement trash = Driver.getDriver().findElement(By.xpath(xpath));
Actions actions = new Actions(Driver.getDriver());
actions.click(trash).build().perform();

}
}
@Given("user clicks on ok button on the popup")
public void user_clicks_on_ok_button_on_the_popup() {
WebDriverWait wait = new WebDriverWait(Driver.getDriver(), 3);
wait.until(ExpectedConditions.alertIsPresent());
Driver.getDriver().switchTo().alert().accept();
reusableMethods.wait(2);

}
@Then("user verify the success message")
public void user_verify_the_success_message() {
reusableMethods.wait(2);
Assert.assertTrue(pages.issueListPage().message.isDisplayed());
}
}
Loading