Skip to content

Commit

Permalink
#2 Add 'Open Project Catalog' Feature
Browse files Browse the repository at this point in the history
- Add: openProjectCatalog.feature, ContentInformationSteps, CatalogPage
- Enhance: HomePage
- Edit: lockArchiveMetadata.feature, uploadFile.feature
  • Loading branch information
helkv committed Jan 7, 2020
1 parent 7851c1e commit c38d426
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 2 deletions.
31 changes: 31 additions & 0 deletions src/main/java/ui/pages/CatalogPage.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package ui.pages;

import static io.cucumber.spring.CucumberTestContext.SCOPE_CUCUMBER_GLUE;

import org.openqa.selenium.WebDriver;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

/**
* Page Object encapsulates the Catalog page.
*
* @author helk
*
*/
@Lazy
@Component
@Scope(SCOPE_CUCUMBER_GLUE)
public class CatalogPage extends BasePage {

@Autowired
public CatalogPage(WebDriver driver) {
super(driver);
}

public String getTitle() {
return driver.getTitle();
}

}
15 changes: 15 additions & 0 deletions src/main/java/ui/pages/HomePage.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static io.cucumber.spring.CucumberTestContext.SCOPE_CUCUMBER_GLUE;

import java.util.ArrayList;
import java.util.List;

import org.openqa.selenium.By;
Expand Down Expand Up @@ -41,6 +42,9 @@ public class HomePage extends BasePage {
@FindBy(id = "side-nav")
private WebElement sideNavigationDiv;

@FindBy(linkText = "Project Catalog")
private WebElement projectCatalogElement;

@Lazy
@Autowired
HomePage homePage;
Expand Down Expand Up @@ -134,6 +138,17 @@ public HomePage openMyLibraries() {
return homePage;
}

public void openProjectCatalog() {
this.projectCatalogElement.click();

// TODO: Rework window handling
wait.until(ExpectedConditions.numberOfWindowsToBe(2));
ArrayList<String> tabs = new ArrayList<>(driver.getWindowHandles());
driver.switchTo().window(tabs.get(1));

wait.until(ExpectedConditions.titleContains("Catalog"));
}

public HomePage navigateTo() {
driver.navigate().to(BasePage.KEEPER_URL);

Expand Down
43 changes: 43 additions & 0 deletions src/test/java/stepdefinitions/ContentInformationSteps.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package stepdefinitions;

import static org.assertj.core.api.Assertions.assertThat;

import org.openqa.selenium.WebDriver;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;

import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;
import ui.pages.CatalogPage;
import ui.pages.HomePage;

/**
* Test Steps: Content Information domain
*
* @author helk
*
*/
public class ContentInformationSteps {

@Autowired
WebDriver driver;

@Lazy
@Autowired
HomePage homePage;

@Lazy
@Autowired
CatalogPage catalogPage;

@When("Open Project Catalog")
public void openProjectCatalog() {
homePage.openProjectCatalog();
}

@Then("Project Catalog Page is opened")
public void projectCatalogPageIsOpened() {
assertThat(catalogPage.getTitle()).isEqualTo("Catalog - KEEPER");
}

}
2 changes: 1 addition & 1 deletion src/test/resources/features/lockArchiveMetadata.feature
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Feature: Lock Archive Metadata
Logged in user can lock the Archive Metadata file of a library.

@KP-19
@KP-21
@LockArchiveMetadata
Scenario: Lock archive metadata
Given Logged in as User
Expand Down
10 changes: 10 additions & 0 deletions src/test/resources/features/openProjectCatalog.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Feature: Open Project Catalog
Logged in user can open the Project Catalog.

@KP-20
@openProjectCatalog
Scenario: Open Project Catalog
Given Logged in as User
When Open Project Catalog
Then Project Catalog Page is opened
#TODO: Project Catalog is displayed correctly
2 changes: 1 addition & 1 deletion src/test/resources/features/uploadFile.feature
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Feature: Upload file
Logged in user can upload a file to a library.

@KP-17
@KP-29
@uploadFile
Scenario: Upload file
Given Logged in as User
Expand Down

0 comments on commit c38d426

Please sign in to comment.