mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-17 13:25:49 +00:00
Add integration tests for Petclinic UI
Integration tests are 2 Selenium tests built on Grid Dynamics JBehave Framework. The tests run against a remote webdriver with Firefox browser.
This commit is contained in:
parent
fe4efae93b
commit
f85da00158
22 changed files with 847 additions and 1 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -1,4 +1,3 @@
|
|||
target/*
|
||||
.settings/*
|
||||
.classpath
|
||||
.project
|
||||
|
@ -29,3 +28,5 @@ bin/*
|
|||
.coverage/*
|
||||
.kitchen/
|
||||
.kitchen.local.yml
|
||||
target
|
||||
*~
|
||||
|
|
BIN
spring-petclinic-it/.DS_Store
vendored
Normal file
BIN
spring-petclinic-it/.DS_Store
vendored
Normal file
Binary file not shown.
15
spring-petclinic-it/README.md
Normal file
15
spring-petclinic-it/README.md
Normal file
|
@ -0,0 +1,15 @@
|
|||
Requisites:
|
||||
- Binary repository for GD JBehave Framework
|
||||
https://nexus.griddynamics.net/nexus/content/repositories/gd_jbehave_framework-snapshots
|
||||
should be added to Maven repositories in `settings.xml`.
|
||||
It requires authentication so it should be configured properly.
|
||||
|
||||
Run test against a remote WebDriver:
|
||||
|
||||
mvn -P runTests clean test -Dthreads=1 \
|
||||
-Dsuite.all=**/*Suite.java -Dsuite.list=UITestsExampleSuite \
|
||||
-Dspring.profiles.active=remote \
|
||||
-Dmeta.filters=-not_impl,-not_in_func,-blocked,-non_ci \
|
||||
-DREMOTE_WEBDRIVER_URL=http://localhost:4444/wd/hub -Dbrowser.version= \
|
||||
-Dpetclinic.url=http://localhost:9966/petclinic
|
||||
|
346
spring-petclinic-it/pom.xml
Normal file
346
spring-petclinic-it/pom.xml
Normal file
|
@ -0,0 +1,346 @@
|
|||
<?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>
|
||||
|
||||
<groupId>pet_clinic_test_example</groupId>
|
||||
<artifactId>pet_clinic_test_example</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
<properties>
|
||||
<suite.all>**/DefaultWebSuite.java</suite.all>
|
||||
<suite.list/>
|
||||
<story.list/>
|
||||
<exclude.story.list/>
|
||||
|
||||
|
||||
<!-- Config File Paths -->
|
||||
<execution.config.file.location>
|
||||
${project.basedir}/src/main/resources/store.properties
|
||||
</execution.config.file.location>
|
||||
<pages.config.file.location>
|
||||
${project.basedir}/src/main/resources/pages.properties
|
||||
</pages.config.file.location>
|
||||
<browser.config.file.location>
|
||||
${project.basedir}/src/main/resources/browser.properties
|
||||
</browser.config.file.location>
|
||||
<runner.config.file.location>
|
||||
${project.basedir}/src/main/resources/jbehave.properties
|
||||
</runner.config.file.location>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
|
||||
|
||||
<jbehave.core.version>3.8</jbehave.core.version>
|
||||
<jbehave.web.version>3.6-beta-1</jbehave.web.version>
|
||||
<selenium.version>2.34.0</selenium.version>
|
||||
<jbehave.site.version>3.1.1</jbehave.site.version>
|
||||
<junit.version>4.11</junit.version>
|
||||
<spring.version>3.2.4.RELEASE</spring.version>
|
||||
<log4j.version>1.2.17</log4j.version>
|
||||
<hamcrest.version>1.3</hamcrest.version>
|
||||
<gdframework.version>1.0-SNAPSHOT</gdframework.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- Grid QA Framework -->
|
||||
<dependency>
|
||||
<groupId>com.griddynamics.qa</groupId>
|
||||
<artifactId>core-framework</artifactId>
|
||||
<version>${gdframework.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.griddynamics.qa</groupId>
|
||||
<artifactId>common-ui-utils</artifactId>
|
||||
<version>${gdframework.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- JBehave -->
|
||||
<dependency>
|
||||
<groupId>org.jbehave.web</groupId>
|
||||
<artifactId>jbehave-web-selenium</artifactId>
|
||||
<version>${jbehave.web.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.seleniumhq.selenium</groupId>
|
||||
<artifactId>selenium-java</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.jbehave</groupId>
|
||||
<artifactId>jbehave-core</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jbehave</groupId>
|
||||
<artifactId>jbehave-core</artifactId>
|
||||
<version>${jbehave.core.version}</version>
|
||||
<classifier>resources</classifier>
|
||||
<type>zip</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jbehave.site</groupId>
|
||||
<artifactId>jbehave-site-resources</artifactId>
|
||||
<version>${jbehave.site.version}</version>
|
||||
<type>zip</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jbehave</groupId>
|
||||
<artifactId>jbehave-navigator</artifactId>
|
||||
<version>${jbehave.core.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Selenium -->
|
||||
<dependency>
|
||||
<groupId>org.seleniumhq.selenium</groupId>
|
||||
<artifactId>selenium-java</artifactId>
|
||||
<version>${selenium.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>excludeTesting</id>
|
||||
<activation>
|
||||
<activeByDefault>true</activeByDefault>
|
||||
</activation>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.jbehave</groupId>
|
||||
<artifactId>jbehave-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
|
||||
<!-- Profile for tests -->
|
||||
<profile>
|
||||
<id>runTests</id>
|
||||
<activation>
|
||||
<activeByDefault>false</activeByDefault>
|
||||
</activation>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.jbehave</groupId>
|
||||
<artifactId>jbehave-maven-plugin</artifactId>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.jettison</groupId>
|
||||
<artifactId>jettison</artifactId>
|
||||
<version>1.3.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<configuration>
|
||||
<includes>
|
||||
<include>${suite.all}</include>
|
||||
</includes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/java</directory>
|
||||
<filtering>true</filtering>
|
||||
<excludes>
|
||||
<exclude>**/*.java</exclude>
|
||||
</excludes>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>browser-profile</directory>
|
||||
<targetPath>browser-profile</targetPath>
|
||||
</resource>
|
||||
</resources>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.jbehave</groupId>
|
||||
<artifactId>jbehave-maven-plugin</artifactId>
|
||||
<version>${jbehave.core.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>unpack-view-resources</id>
|
||||
<phase>process-resources</phase>
|
||||
<goals>
|
||||
<goal>unpack-view-resources</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>embeddable-stories</id>
|
||||
|
||||
<phase>test</phase>
|
||||
<goals>
|
||||
<goal>run-stories-as-embeddables</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<ignoreFailureInStories>${jbehave.ignoreFailureInStories}</ignoreFailureInStories>
|
||||
<ignoreFailureInView>${jbehave.ignoreFailureInView}</ignoreFailureInView>
|
||||
<storyTimeoutInSecs>${jbehave.storyTimeoutInSecs}</storyTimeoutInSecs>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>${log4j.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Only needed if groovy-based MetaFilters are used -->
|
||||
<dependency>
|
||||
<groupId>org.codehaus.groovy</groupId>
|
||||
<artifactId>groovy-all</artifactId>
|
||||
<version>1.8.4</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
<version>2.5</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.hamcrest</groupId>
|
||||
<artifactId>hamcrest-all</artifactId>
|
||||
<version>${hamcrest.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>properties-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>read</id>
|
||||
<phase>initialize</phase>
|
||||
<goals>
|
||||
<goal>read-project-properties</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<files>
|
||||
<file>${execution.config.file.location}</file>
|
||||
<file>${pages.config.file.location}</file>
|
||||
<file>${browser.config.file.location}</file>
|
||||
<file>${runner.config.file.location}</file>
|
||||
</files>
|
||||
<quiet>true</quiet>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>export</id>
|
||||
<phase>initialize</phase>
|
||||
<goals>
|
||||
<goal>set-system-properties</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<properties>
|
||||
<property>
|
||||
<name>execution.config.file.location</name>
|
||||
<value>${execution.config.file.location}</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>pages.config.file.location</name>
|
||||
<value>${pages.config.file.location}</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>runner.config.file.location</name>
|
||||
<value>${runner.config.file.location}</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>browser.config.file.location</name>
|
||||
<value>${browser.config.file.location}</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>jbehave.ignoreFailureInStories</name>
|
||||
<value>${jbehave.ignoreFailureInStories}</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>jbehave.ignoreFailureInView</name>
|
||||
<value>${jbehave.ignoreFailureInView}</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>jbehave.storyTimeoutInSecs</name>
|
||||
<value>${jbehave.storyTimeoutInSecs}</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>threads</name>
|
||||
<value>${threads}</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>meta.filters</name>
|
||||
<value>${meta.filters}</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>REMOTE_WEBDRIVER_URL</name>
|
||||
<value>${REMOTE_WEBDRIVER_URL}</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>browser</name>
|
||||
<value>${browser}</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>remoteWebDriver</name>
|
||||
<value>${remoteWebDriver}</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>spring.profiles.active</name>
|
||||
<value>${spring.profiles.active}</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>suite.all</name>
|
||||
<value>${suite.all}</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>suite.list</name>
|
||||
<value>${suite.list}</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>story.list</name>
|
||||
<value>${story.list}</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>exclude.story.list</name>
|
||||
<value>${exclude.story.list}</value>
|
||||
</property>
|
||||
</properties>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,21 @@
|
|||
package com.griddynamics.web;
|
||||
|
||||
/**
|
||||
* @author lzakharova
|
||||
*/
|
||||
public class PetClinicStoreHost {
|
||||
|
||||
private String petClinicUrl;
|
||||
|
||||
public PetClinicStoreHost() {
|
||||
}
|
||||
|
||||
public String getPetClinicUrl() {
|
||||
return petClinicUrl;
|
||||
}
|
||||
|
||||
public void setPetClinicUrl(String petClinicUrl) {
|
||||
this.petClinicUrl = petClinicUrl;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package com.griddynamics.web.blocks;
|
||||
|
||||
|
||||
import com.griddynamics.qa.ui.ElementBlock;
|
||||
import org.jbehave.web.selenium.WebDriverProvider;
|
||||
|
||||
import static com.griddynamics.web.blocks.HeaderBlockData.*;
|
||||
|
||||
/**
|
||||
* @author lzakharova
|
||||
*/
|
||||
public class HeaderBlock extends ElementBlock {
|
||||
|
||||
public HeaderBlock(WebDriverProvider provider) {
|
||||
super(provider, HEADER_BLOCK_NAME, headerBlockLoc);
|
||||
|
||||
addElement(HOME_MENU, homeMenuLoc);
|
||||
addElement(FIND_OWNERS_MENU, findOwnersMenuLoc);
|
||||
addElement(VETERINARIANS_MENU, veterinariansMenuLoc);
|
||||
addElement(ERROR_MENU, errorMenuLoc);
|
||||
addElement(HELP_MENU, helpMenuLoc);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package com.griddynamics.web.blocks;
|
||||
|
||||
|
||||
import org.openqa.selenium.By;
|
||||
|
||||
/**
|
||||
* @author lzakharova
|
||||
*/
|
||||
public class HeaderBlockData {
|
||||
|
||||
public final static String HEADER_BLOCK_NAME = "Header";
|
||||
public final static String HEADER_BLOCK_COMMON_LOC = "//div[@class='navbar']";
|
||||
public final static By headerBlockLoc = By.xpath(HEADER_BLOCK_COMMON_LOC);
|
||||
|
||||
|
||||
public final static String HOME_MENU = "Home menu";
|
||||
public final static By homeMenuLoc = By.xpath(HEADER_BLOCK_COMMON_LOC + "//a[contains(text(), 'Home')]");
|
||||
|
||||
public final static String FIND_OWNERS_MENU = "Find owners menu";
|
||||
public final static By findOwnersMenuLoc = By.xpath(HEADER_BLOCK_COMMON_LOC + "//a[contains(text(), 'Find owners')]");
|
||||
|
||||
public final static String VETERINARIANS_MENU = "Veterinarians menu";
|
||||
public final static By veterinariansMenuLoc = By.xpath(HEADER_BLOCK_COMMON_LOC + "//a[contains(text(), 'Veterinarians')]");
|
||||
|
||||
public final static String ERROR_MENU = "Error menu";
|
||||
public final static By errorMenuLoc = By.xpath(HEADER_BLOCK_COMMON_LOC + "//a[contains(text(), 'Error')]");
|
||||
|
||||
public final static String HELP_MENU = "Help menu";
|
||||
public final static By helpMenuLoc = By.xpath(HEADER_BLOCK_COMMON_LOC + "//a[contains(text(), 'Help')]");
|
||||
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package com.griddynamics.web.pages;
|
||||
|
||||
import com.griddynamics.qa.ui.AbstractPage;
|
||||
import com.griddynamics.qa.ui.Pages;
|
||||
import org.jbehave.web.selenium.WebDriverProvider;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author lzakharova
|
||||
*/
|
||||
|
||||
public class CustomPages extends Pages {
|
||||
|
||||
@Autowired
|
||||
private WebDriverProvider driverProvider;
|
||||
|
||||
public CustomPages() {
|
||||
}
|
||||
|
||||
public CustomPages(WebDriverProvider driverProvider, Map<String, AbstractPage> pageMappings) {
|
||||
this.driverProvider = driverProvider;
|
||||
pagesMap.putAll(pageMappings);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,116 @@
|
|||
package com.griddynamics.web.pages;
|
||||
|
||||
import com.griddynamics.qa.ui.AbstractPage;
|
||||
import com.griddynamics.web.PetClinicStoreHost;
|
||||
import com.griddynamics.web.blocks.HeaderBlock;
|
||||
import org.jbehave.web.selenium.WebDriverProvider;
|
||||
import org.openqa.selenium.By;
|
||||
import org.openqa.selenium.TimeoutException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import static com.griddynamics.qa.logger.LoggerFactory.getLogger;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* @author lzakharova
|
||||
*/
|
||||
|
||||
public abstract class PetClinicCommonPage extends AbstractPage {
|
||||
|
||||
public static final String PAGE_TITLE = "Page title";
|
||||
public static final By pageTitleLoc = By.xpath("//h2");
|
||||
|
||||
@Autowired
|
||||
public PetClinicStoreHost petClinicStoreHost;
|
||||
|
||||
|
||||
private String currentPageTitle;
|
||||
private String currentPageUri;
|
||||
|
||||
private HeaderBlock headerBlock;
|
||||
|
||||
|
||||
protected PetClinicCommonPage(WebDriverProvider driverProvider) {
|
||||
super(driverProvider);
|
||||
initElements();
|
||||
}
|
||||
|
||||
protected PetClinicCommonPage(WebDriverProvider driverProvider, String currentPageUri, String currentPageTitle) {
|
||||
this(driverProvider);
|
||||
setCurrentPageUri(currentPageUri);
|
||||
setCurrentPageTitle(currentPageTitle);
|
||||
initElements();
|
||||
}
|
||||
|
||||
private void initElements() {
|
||||
addElement(PAGE_TITLE, pageTitleLoc);
|
||||
|
||||
headerBlock = new HeaderBlock(getDriverProvider());
|
||||
|
||||
addBlock(headerBlock);
|
||||
}
|
||||
|
||||
public String getBaseURL() {
|
||||
return petClinicStoreHost.getPetClinicUrl();
|
||||
}
|
||||
|
||||
|
||||
public String getCurrentPageTitle() {
|
||||
return currentPageTitle;
|
||||
}
|
||||
|
||||
public void setCurrentPageTitle(String currentPageTitle) {
|
||||
this.currentPageTitle = currentPageTitle;
|
||||
}
|
||||
|
||||
public String getCurrentPageUri() {
|
||||
return currentPageUri;
|
||||
}
|
||||
|
||||
public void setCurrentPageUri(String currentPageUri) {
|
||||
this.currentPageUri = currentPageUri;
|
||||
}
|
||||
|
||||
protected String getPageRelativeURL() {
|
||||
return currentPageUri;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPageURL() {
|
||||
return getBaseURL() + ("/" + getPageRelativeURL()).replaceAll("//", "/");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkCurrentPage() {
|
||||
return checkURL() ;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void assertCurrentPage() {
|
||||
assertTrue("AssertPage Failed due to wrong URL OR mandatory element absence. " +
|
||||
"Expected URL: " + getPageURL() + "; Got: " + getCurrentUrl(),
|
||||
checkCurrentPage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openPage() {
|
||||
int timeoutExc = 0;
|
||||
int attempt = 0;
|
||||
while (timeoutExc < PAGE_OPEN_ATTEMPTS_NUMBER) {
|
||||
int i = 1;
|
||||
try {
|
||||
while (!checkCurrentPage() && i <= PAGE_OPEN_ATTEMPTS_NUMBER) {
|
||||
attempt++;
|
||||
open(attempt);
|
||||
i++;
|
||||
}
|
||||
} catch (TimeoutException e) {
|
||||
timeoutExc++;
|
||||
getLogger().info("Caught TimeoutException. " + e.getMessage());
|
||||
continue;
|
||||
}
|
||||
timeoutExc = PAGE_OPEN_ATTEMPTS_NUMBER;
|
||||
}
|
||||
assertCurrentPage();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package com.griddynamics.web.pages;
|
||||
|
||||
import org.jbehave.web.selenium.WebDriverProvider;
|
||||
import org.openqa.selenium.By;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* @author lzakharova
|
||||
*/
|
||||
public class PetClinicFindOwnersPage extends PetClinicCommonPage {
|
||||
|
||||
public static final String FIND_OWNER_FIELD = "Find Owner field";
|
||||
public static final By findOwnerFieldLoc = By.xpath("//input[@id='lastName']");
|
||||
|
||||
public static final String FIND_OWNER_BUTTON = "Find Owner button";
|
||||
public static final By findOwnerButtonLoc = By.xpath("//button[@type='submit']");
|
||||
|
||||
public static final String OWNERS_TABLE = "Owners table";
|
||||
public static final By ownersTableLoc = By.xpath("//table[@id='owners']");
|
||||
|
||||
|
||||
public PetClinicFindOwnersPage(WebDriverProvider driverProvider, String currentPageUri, String currentPageTitle) {
|
||||
super(driverProvider, currentPageUri, currentPageTitle);
|
||||
|
||||
addElement(FIND_OWNER_FIELD, findOwnerFieldLoc);
|
||||
addElement(FIND_OWNER_BUTTON, findOwnerButtonLoc);
|
||||
addElement(OWNERS_TABLE, ownersTableLoc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void assertCurrentPage() {
|
||||
super.assertCurrentPage();
|
||||
assertTrue(PAGE_TITLE + " is not displayed", isElementDisplayedOnPage(PAGE_TITLE));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
package com.griddynamics.web.pages;
|
||||
|
||||
import org.jbehave.web.selenium.WebDriverProvider;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* @author lzakharova
|
||||
*/
|
||||
public class PetClinicHomePage extends PetClinicCommonPage {
|
||||
|
||||
public PetClinicHomePage(WebDriverProvider driverProvider, String currentPageUri, String currentPageTitle) {
|
||||
super(driverProvider, currentPageUri, currentPageTitle);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void assertCurrentPage() {
|
||||
super.assertCurrentPage();
|
||||
assertTrue(PAGE_TITLE + " is not displayed", isElementDisplayedOnPage(PAGE_TITLE));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
package com.griddynamics.web.suits;
|
||||
|
||||
|
||||
import com.griddynamics.qa.framework.WebStoriesRunner;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author lzakharova
|
||||
*/
|
||||
|
||||
public class UITestsExampleSuite extends WebStoriesRunner {
|
||||
protected static String contextPath = "/com/griddynamics/context/webApplicationContext.xml";
|
||||
|
||||
public UITestsExampleSuite() {
|
||||
super(contextPath);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> excludeStories() {
|
||||
return new ArrayList<String>() {
|
||||
{
|
||||
add("**/web/**/*Given*.story");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> includeStories() {
|
||||
return new ArrayList<String>() {
|
||||
{
|
||||
add("**/stories/uitests/**/**.story");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeRun() {
|
||||
}
|
||||
}
|
10
spring-petclinic-it/src/main/resources/browser.properties
Normal file
10
spring-petclinic-it/src/main/resources/browser.properties
Normal file
|
@ -0,0 +1,10 @@
|
|||
#Merged
|
||||
#Fri Oct 04 02:59:15 CDT 2013
|
||||
browser.proxy.ip=
|
||||
browser.proxy.port=8080
|
||||
browser.proxy.user=test
|
||||
browser.proxy.password=test
|
||||
page.timeout.ms=70000
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:aop="http://www.springframework.org/schema/aop"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/aop
|
||||
http://www.springframework.org/schema/aop/spring-aop-3.1.xsd">
|
||||
|
||||
<bean id="petClinicHomePage" class="com.griddynamics.web.pages.PetClinicHomePage">
|
||||
<constructor-arg name="driverProvider" ref="driverProvider"/>
|
||||
<constructor-arg name="currentPageTitle">
|
||||
<value>${petClinicHomePageTitle}</value>
|
||||
</constructor-arg>
|
||||
<constructor-arg name="currentPageUri">
|
||||
<value>${petClinicHomePageUrl}</value>
|
||||
</constructor-arg>
|
||||
</bean>
|
||||
|
||||
<bean id="petClinicFindOwnersPage" class="com.griddynamics.web.pages.PetClinicFindOwnersPage">
|
||||
<constructor-arg name="driverProvider" ref="driverProvider"/>
|
||||
<constructor-arg name="currentPageTitle">
|
||||
<value>${petClinicFindOwnersPageTitle}</value>
|
||||
</constructor-arg>
|
||||
<constructor-arg name="currentPageUri">
|
||||
<value>${petClinicFindOwnersPageUrl}</value>
|
||||
</constructor-arg>
|
||||
</bean>
|
||||
|
||||
<bean id="pages" class="com.griddynamics.web.pages.CustomPages" scope="thread">
|
||||
<constructor-arg index="0" ref="driverProvider"/>
|
||||
<constructor-arg index="1" ref="pageMatching"/>
|
||||
<aop:scoped-proxy/>
|
||||
</bean>
|
||||
|
||||
<bean id="pageMatching" class="org.springframework.beans.factory.config.MapFactoryBean">
|
||||
<property name="targetMapClass" value="java.util.HashMap"/>
|
||||
<property name="sourceMap">
|
||||
<map>
|
||||
<entry key="Pet Clinic Home" value-ref="petClinicHomePage"/>
|
||||
<entry key="Pet Clinic Find Owners" value-ref="petClinicFindOwnersPage"/>
|
||||
</map>
|
||||
</property>
|
||||
</bean>
|
||||
</beans>
|
|
@ -0,0 +1,20 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans.xsd"
|
||||
>
|
||||
|
||||
<bean id="placeholderProperties" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
|
||||
depends-on="environment">
|
||||
<property name="locations">
|
||||
<list>
|
||||
<value>classpath:pages.properties</value>
|
||||
<value>classpath:store.properties</value>
|
||||
<value>classpath:browser.properties</value>
|
||||
<value>classpath:jbehave.properties</value>
|
||||
</list>
|
||||
</property>
|
||||
<property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE"/>
|
||||
</bean>
|
||||
</beans>
|
|
@ -0,0 +1,50 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/context
|
||||
http://www.springframework.org/schema/context/spring-context.xsd">
|
||||
|
||||
<context:component-scan base-package="com.griddynamics.qa.ui.steps"/>
|
||||
<context:annotation-config/>
|
||||
|
||||
<import resource="classpath*:com/griddynamics/context/uiPropertiesContext.xml"/>
|
||||
<import resource="classpath*:com/griddynamics/context/pagesBeans.xml"/>
|
||||
|
||||
<bean id="webDriverProvider" class="org.jbehave.web.selenium.PerStoryWebDriverSteps" >
|
||||
<constructor-arg ref="driverProvider"/>
|
||||
</bean>
|
||||
|
||||
<bean id="screenshots" class="com.griddynamics.qa.framework.CustomWebDriverScreenshotOnFailure">
|
||||
<constructor-arg ref="driverProvider"/>
|
||||
</bean>
|
||||
|
||||
<bean class="org.springframework.beans.factory.config.CustomScopeConfigurer">
|
||||
<property name="scopes">
|
||||
<map>
|
||||
<entry key="thread">
|
||||
<bean class="org.springframework.context.support.SimpleThreadScope"/>
|
||||
</entry>
|
||||
</map>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
|
||||
<bean id="petClinicStoreHost" class="com.griddynamics.web.PetClinicStoreHost" >
|
||||
<property name="petClinicUrl">
|
||||
<value>${petclinic.url}</value>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<beans profile="remote">
|
||||
<bean id="driverProvider" class="org.jbehave.web.selenium.RemoteWebDriverProvider">
|
||||
</bean>
|
||||
</beans>
|
||||
|
||||
<beans profile="local">
|
||||
<bean id="driverProvider" class="org.jbehave.web.selenium.PropertyWebDriverProvider">
|
||||
</bean>
|
||||
</beans>
|
||||
</beans>
|
|
@ -0,0 +1,8 @@
|
|||
Meta:
|
||||
@smoke
|
||||
|
||||
|
||||
Scenario: Check Home Page
|
||||
|
||||
Given customer is on Pet Clinic Home Page
|
||||
Then element Page title has text Welcome
|
|
@ -0,0 +1,12 @@
|
|||
Meta:
|
||||
@smoke
|
||||
|
||||
|
||||
Scenario: Check Find Owner Page
|
||||
|
||||
Given customer is on Pet Clinic Home Page
|
||||
When customer clicks Find owners menu
|
||||
Then Pet Clinic Find Owners Page is opened
|
||||
|
||||
When customer clicks Find Owner button
|
||||
Then Owners table is displayed on page
|
|
@ -0,0 +1,8 @@
|
|||
#Merged
|
||||
#Fri Oct 04 02:59:19 CDT 2013
|
||||
browser=firefox
|
||||
jbehave.ignoreFailureInView=true
|
||||
spring.profiles.active=local
|
||||
jbehave.ignoreFailureInStories=true
|
||||
jbehave.storyTimeoutInSecs=5500
|
||||
threads=1
|
7
spring-petclinic-it/src/main/resources/log4j.properties
Normal file
7
spring-petclinic-it/src/main/resources/log4j.properties
Normal file
|
@ -0,0 +1,7 @@
|
|||
# ***** Set root logger level to INFO and its three appenders
|
||||
log4j.rootLogger=INFO, stdout
|
||||
|
||||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.stdout.layout.ConversionPattern=%d %p (%t) (%F:%L) - %m%n
|
||||
|
5
spring-petclinic-it/src/main/resources/pages.properties
Normal file
5
spring-petclinic-it/src/main/resources/pages.properties
Normal file
|
@ -0,0 +1,5 @@
|
|||
petClinicHomePageUrl=/
|
||||
petClinicHomePageTitle=PetClinic :: a Spring Framework demonstration
|
||||
|
||||
petClinicFindOwnersPageUrl=/owners/find.html
|
||||
petClinicFindOwnersPageTitle=PetClinic :: a Spring Framework demonstration
|
2
spring-petclinic-it/src/main/resources/store.properties
Normal file
2
spring-petclinic-it/src/main/resources/store.properties
Normal file
|
@ -0,0 +1,2 @@
|
|||
#petclinic.url=http://localhost:9966/petclinic
|
||||
|
Loading…
Reference in a new issue