mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-20 23:05:49 +00:00
Add selenium and two selenium tests to the project
This commit is contained in:
parent
d129f24d9f
commit
1260b6ec5f
5 changed files with 353 additions and 219 deletions
|
@ -6,6 +6,7 @@ services:
|
||||||
- "8080:8080"
|
- "8080:8080"
|
||||||
links:
|
links:
|
||||||
- mysql:mysql
|
- mysql:mysql
|
||||||
|
- selenium
|
||||||
command: java -jar ./target/*.jar
|
command: java -jar ./target/*.jar
|
||||||
mysql:
|
mysql:
|
||||||
image: mysql
|
image: mysql
|
||||||
|
@ -15,4 +16,9 @@ services:
|
||||||
- MYSQL_ROOT_PASSWORD=root
|
- MYSQL_ROOT_PASSWORD=root
|
||||||
- MYSQL_DATABASE=test
|
- MYSQL_DATABASE=test
|
||||||
volumes:
|
volumes:
|
||||||
- "./conf.d:/etc/mysql/conf.d:ro"
|
- "./conf.d:/etc/mysql/conf.d:ro"
|
||||||
|
selenium:
|
||||||
|
image: selenium/standalone-firefox
|
||||||
|
shm_size: 2g
|
||||||
|
ports:
|
||||||
|
- "4444:4444"
|
||||||
|
|
444
pom.xml
444
pom.xml
|
@ -1,229 +1,237 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>org.springframework.samples</groupId>
|
<groupId>org.springframework.samples</groupId>
|
||||||
<artifactId>spring-petclinic</artifactId>
|
<artifactId>spring-petclinic</artifactId>
|
||||||
<version>1.5.1</version>
|
<version>1.5.1</version>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-parent</artifactId>
|
|
||||||
<version>1.5.1.RELEASE</version>
|
|
||||||
</parent>
|
|
||||||
<name>petclinic</name>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
|
|
||||||
<!-- Generic properties -->
|
|
||||||
<java.version>1.8</java.version>
|
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
|
||||||
|
|
||||||
<!-- Web dependencies -->
|
|
||||||
<webjars-bootstrap.version>3.3.6</webjars-bootstrap.version>
|
|
||||||
<webjars-jquery-ui.version>1.11.4</webjars-jquery-ui.version>
|
|
||||||
<webjars-jquery.version>2.2.4</webjars-jquery.version>
|
|
||||||
<wro4j.version>1.8.0</wro4j.version>
|
|
||||||
|
|
||||||
<thymeleaf.version>3.0.2.RELEASE</thymeleaf.version>
|
|
||||||
|
|
||||||
<cobertura.version>2.7</cobertura.version>
|
|
||||||
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<!-- Spring and Spring Boot dependencies -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-cache</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-thymeleaf</artifactId>
|
|
||||||
<exclusions>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>nz.net.ultraq.thymeleaf</groupId>
|
|
||||||
<artifactId>thymeleaf-layout-dialect</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-test</artifactId>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Databases - Uses HSQL by default -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.hsqldb</groupId>
|
|
||||||
<artifactId>hsqldb</artifactId>
|
|
||||||
<scope>runtime</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>mysql</groupId>
|
|
||||||
<artifactId>mysql-connector-java</artifactId>
|
|
||||||
<scope>runtime</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- caching -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>javax.cache</groupId>
|
|
||||||
<artifactId>cache-api</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.ehcache</groupId>
|
|
||||||
<artifactId>ehcache</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- webjars -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.webjars</groupId>
|
|
||||||
<artifactId>webjars-locator</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.webjars</groupId>
|
|
||||||
<artifactId>jquery</artifactId>
|
|
||||||
<version>${webjars-jquery.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.webjars</groupId>
|
|
||||||
<artifactId>jquery-ui</artifactId>
|
|
||||||
<version>${webjars-jquery-ui.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.webjars</groupId>
|
|
||||||
<artifactId>bootstrap</artifactId>
|
|
||||||
<version>${webjars-bootstrap.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<!-- end of webjars -->
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-devtools</artifactId>
|
|
||||||
<scope>runtime</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
<executions>
|
<version>1.5.1.RELEASE</version>
|
||||||
<execution>
|
</parent>
|
||||||
<!-- Spring Boot Actuator displays build-related information
|
<name>petclinic</name>
|
||||||
if a META-INF/build-info.properties file is present -->
|
|
||||||
<goals>
|
|
||||||
<goal>build-info</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<additionalProperties>
|
|
||||||
<encoding.source>${project.build.sourceEncoding}</encoding.source>
|
|
||||||
<encoding.reporting>${project.reporting.outputEncoding}</encoding.reporting>
|
|
||||||
<java.source>${maven.compiler.source}</java.source>
|
|
||||||
<java.target>${maven.compiler.target}</java.target>
|
|
||||||
</additionalProperties>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.codehaus.mojo</groupId>
|
|
||||||
<artifactId>cobertura-maven-plugin</artifactId>
|
|
||||||
<version>${cobertura.version}</version>
|
|
||||||
<configuration>
|
|
||||||
<check />
|
|
||||||
</configuration>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<goals>
|
|
||||||
<goal>clean</goal>
|
|
||||||
<goal>check</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
|
|
||||||
<!-- Spring Boot Actuator displays build-related information if a git.properties
|
<properties>
|
||||||
file is present at the classpath -->
|
|
||||||
<plugin>
|
|
||||||
<groupId>pl.project13.maven</groupId>
|
|
||||||
<artifactId>git-commit-id-plugin</artifactId>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<goals>
|
|
||||||
<goal>revision</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
<configuration>
|
|
||||||
<verbose>true</verbose>
|
|
||||||
<dateFormat>yyyy-MM-dd'T'HH:mm:ssZ</dateFormat>
|
|
||||||
<generateGitPropertiesFile>true</generateGitPropertiesFile>
|
|
||||||
<generateGitPropertiesFilename>${project.build.outputDirectory}/git.properties
|
|
||||||
</generateGitPropertiesFilename>
|
|
||||||
<failOnNoGitDirectory>false</failOnNoGitDirectory>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
|
|
||||||
<plugin>
|
<!-- Generic properties -->
|
||||||
<groupId>ro.isdc.wro4j</groupId>
|
<java.version>1.8</java.version>
|
||||||
<artifactId>wro4j-maven-plugin</artifactId>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<version>${wro4j.version}</version>
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
<executions>
|
|
||||||
<execution>
|
<!-- Web dependencies -->
|
||||||
<phase>generate-resources</phase>
|
<webjars-bootstrap.version>3.3.6</webjars-bootstrap.version>
|
||||||
<goals>
|
<webjars-jquery-ui.version>1.11.4</webjars-jquery-ui.version>
|
||||||
<goal>run</goal>
|
<webjars-jquery.version>2.2.4</webjars-jquery.version>
|
||||||
</goals>
|
<wro4j.version>1.8.0</wro4j.version>
|
||||||
</execution>
|
|
||||||
</executions>
|
<thymeleaf.version>3.0.2.RELEASE</thymeleaf.version>
|
||||||
<configuration>
|
|
||||||
<wroManagerFactory>ro.isdc.wro.maven.plugin.manager.factory.ConfigurableWroManagerFactory</wroManagerFactory>
|
<cobertura.version>2.7</cobertura.version>
|
||||||
<cssDestinationFolder>${project.build.directory}/classes/static/resources/css</cssDestinationFolder>
|
|
||||||
<wroFile>${basedir}/src/main/wro/wro.xml</wroFile>
|
<selenium-java.version>3.4.0</selenium-java.version>
|
||||||
<extraConfigFile>${basedir}/src/main/wro/wro.properties</extraConfigFile>
|
</properties>
|
||||||
<contextFolder>${basedir}/src/main/less</contextFolder>
|
|
||||||
</configuration>
|
<dependencies>
|
||||||
<dependencies>
|
<!-- Spring and Spring Boot dependencies -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-cache</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-thymeleaf</artifactId>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>nz.net.ultraq.thymeleaf</groupId>
|
||||||
|
<artifactId>thymeleaf-layout-dialect</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Databases - Uses HSQL by default -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.hsqldb</groupId>
|
||||||
|
<artifactId>hsqldb</artifactId>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>mysql</groupId>
|
||||||
|
<artifactId>mysql-connector-java</artifactId>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- caching -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>javax.cache</groupId>
|
||||||
|
<artifactId>cache-api</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.ehcache</groupId>
|
||||||
|
<artifactId>ehcache</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- webjars -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.webjars</groupId>
|
||||||
|
<artifactId>webjars-locator</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.webjars</groupId>
|
||||||
|
<artifactId>jquery</artifactId>
|
||||||
|
<version>${webjars-jquery.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.webjars</groupId>
|
||||||
|
<artifactId>jquery-ui</artifactId>
|
||||||
|
<version>${webjars-jquery-ui.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
<groupId>org.webjars</groupId>
|
<groupId>org.webjars</groupId>
|
||||||
<artifactId>bootstrap</artifactId>
|
<artifactId>bootstrap</artifactId>
|
||||||
<version>${webjars-bootstrap.version}</version>
|
<version>${webjars-bootstrap.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
<!-- end of webjars -->
|
||||||
</plugin>
|
|
||||||
</plugins>
|
<dependency>
|
||||||
</build>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<reporting>
|
<artifactId>spring-boot-devtools</artifactId>
|
||||||
<plugins>
|
<scope>runtime</scope>
|
||||||
<!-- integrate maven-cobertura-plugin to project site -->
|
</dependency>
|
||||||
<plugin>
|
|
||||||
<groupId>org.codehaus.mojo</groupId>
|
<!--Selenium-->
|
||||||
<artifactId>cobertura-maven-plugin</artifactId>
|
<dependency>
|
||||||
<version>${cobertura.version}</version>
|
<groupId>org.seleniumhq.selenium</groupId>
|
||||||
<configuration>
|
<artifactId>selenium-java</artifactId>
|
||||||
<formats>
|
<version>${selenium-java.version}</version>
|
||||||
<format>html</format>
|
</dependency>
|
||||||
</formats>
|
</dependencies>
|
||||||
<check />
|
|
||||||
</configuration>
|
<build>
|
||||||
</plugin>
|
<plugins>
|
||||||
</plugins>
|
<plugin>
|
||||||
</reporting>
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<!-- Spring Boot Actuator displays build-related information
|
||||||
|
if a META-INF/build-info.properties file is present -->
|
||||||
|
<goals>
|
||||||
|
<goal>build-info</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<additionalProperties>
|
||||||
|
<encoding.source>${project.build.sourceEncoding}</encoding.source>
|
||||||
|
<encoding.reporting>${project.reporting.outputEncoding}</encoding.reporting>
|
||||||
|
<java.source>${maven.compiler.source}</java.source>
|
||||||
|
<java.target>${maven.compiler.target}</java.target>
|
||||||
|
</additionalProperties>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
|
<artifactId>cobertura-maven-plugin</artifactId>
|
||||||
|
<version>${cobertura.version}</version>
|
||||||
|
<configuration>
|
||||||
|
<check/>
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>clean</goal>
|
||||||
|
<goal>check</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
|
<!-- Spring Boot Actuator displays build-related information if a git.properties
|
||||||
|
file is present at the classpath -->
|
||||||
|
<plugin>
|
||||||
|
<groupId>pl.project13.maven</groupId>
|
||||||
|
<artifactId>git-commit-id-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>revision</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
<configuration>
|
||||||
|
<verbose>true</verbose>
|
||||||
|
<dateFormat>yyyy-MM-dd'T'HH:mm:ssZ</dateFormat>
|
||||||
|
<generateGitPropertiesFile>true</generateGitPropertiesFile>
|
||||||
|
<generateGitPropertiesFilename>${project.build.outputDirectory}/git.properties
|
||||||
|
</generateGitPropertiesFilename>
|
||||||
|
<failOnNoGitDirectory>false</failOnNoGitDirectory>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
|
<plugin>
|
||||||
|
<groupId>ro.isdc.wro4j</groupId>
|
||||||
|
<artifactId>wro4j-maven-plugin</artifactId>
|
||||||
|
<version>${wro4j.version}</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>generate-resources</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>run</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
<configuration>
|
||||||
|
<wroManagerFactory>ro.isdc.wro.maven.plugin.manager.factory.ConfigurableWroManagerFactory</wroManagerFactory>
|
||||||
|
<cssDestinationFolder>${project.build.directory}/classes/static/resources/css</cssDestinationFolder>
|
||||||
|
<wroFile>${basedir}/src/main/wro/wro.xml</wroFile>
|
||||||
|
<extraConfigFile>${basedir}/src/main/wro/wro.properties</extraConfigFile>
|
||||||
|
<contextFolder>${basedir}/src/main/less</contextFolder>
|
||||||
|
</configuration>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.webjars</groupId>
|
||||||
|
<artifactId>bootstrap</artifactId>
|
||||||
|
<version>${webjars-bootstrap.version}</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
<reporting>
|
||||||
|
<plugins>
|
||||||
|
<!-- integrate maven-cobertura-plugin to project site -->
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
|
<artifactId>cobertura-maven-plugin</artifactId>
|
||||||
|
<version>${cobertura.version}</version>
|
||||||
|
<configuration>
|
||||||
|
<formats>
|
||||||
|
<format>html</format>
|
||||||
|
</formats>
|
||||||
|
<check/>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</reporting>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
47
src/test/java/nl/utwente/bpsd/selenium/AddOwnerTest.java
Normal file
47
src/test/java/nl/utwente/bpsd/selenium/AddOwnerTest.java
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
package nl.utwente.bpsd.selenium;
|
||||||
|
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.experimental.categories.Category;
|
||||||
|
import org.openqa.selenium.By;
|
||||||
|
import org.openqa.selenium.support.ui.ExpectedConditions;
|
||||||
|
import org.openqa.selenium.support.ui.Select;
|
||||||
|
import org.openqa.selenium.support.ui.WebDriverWait;
|
||||||
|
|
||||||
|
import java.net.MalformedURLException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Martijn
|
||||||
|
* @since 21-6-2017.
|
||||||
|
*/
|
||||||
|
public class AddOwnerTest extends SeleniumBaseTest {
|
||||||
|
public AddOwnerTest() throws MalformedURLException {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Category(SeleniumBaseTest.class)
|
||||||
|
public void addOwnerTest() {
|
||||||
|
driver.get(BASE_URL+"/owners/new");
|
||||||
|
|
||||||
|
//Add an owner
|
||||||
|
fillTextField(By.name("firstName"), "Sophie");
|
||||||
|
fillTextField(By.name("lastName"), "Lathouwers");
|
||||||
|
fillTextField(By.name("address"), "Homeroad 12");
|
||||||
|
fillTextField(By.name("city"), "Enschede");
|
||||||
|
fillTextField(By.name("telephone"), "0534890000");
|
||||||
|
driver.findElement(By.name("telephone")).submit();
|
||||||
|
Assert.assertTrue(pageContainsText("Sophie Lathouwers"));
|
||||||
|
|
||||||
|
//Add a pet
|
||||||
|
new WebDriverWait(driver, 3).until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.linkText("Add New Pet")));
|
||||||
|
driver.findElement(By.linkText("Add New Pet")).click();
|
||||||
|
fillTextField(By.name("name"), "Thumper");
|
||||||
|
fillTextField(By.name("birthDate"), "1942/08/09");
|
||||||
|
new Select(driver.findElement(By.name("type"))).selectByValue("hamster");
|
||||||
|
driver.findElement(By.name("name")).submit();
|
||||||
|
|
||||||
|
Assert.assertTrue(pageContainsText("Thumper"));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
30
src/test/java/nl/utwente/bpsd/selenium/FindOwnerTest.java
Normal file
30
src/test/java/nl/utwente/bpsd/selenium/FindOwnerTest.java
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
package nl.utwente.bpsd.selenium;
|
||||||
|
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.experimental.categories.Category;
|
||||||
|
import org.openqa.selenium.By;
|
||||||
|
import org.openqa.selenium.support.ui.ExpectedConditions;
|
||||||
|
import org.openqa.selenium.support.ui.WebDriverWait;
|
||||||
|
|
||||||
|
import java.net.MalformedURLException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Martijn
|
||||||
|
* @since 21-6-2017.
|
||||||
|
*/
|
||||||
|
public class FindOwnerTest extends SeleniumBaseTest {
|
||||||
|
public FindOwnerTest() throws MalformedURLException {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Category(SeleniumBaseTest.class)
|
||||||
|
public void findOwnerTest() {
|
||||||
|
driver.get(BASE_URL+"/owners/find");
|
||||||
|
fillTextField(By.name("lastName"),"Coleman");
|
||||||
|
driver.findElement(By.name("lastName")).submit();
|
||||||
|
Assert.assertTrue(driver.findElementsByXPath("//*[text()='Jean Coleman']").size() == 1);
|
||||||
|
}
|
||||||
|
}
|
43
src/test/java/nl/utwente/bpsd/selenium/SeleniumBaseTest.java
Normal file
43
src/test/java/nl/utwente/bpsd/selenium/SeleniumBaseTest.java
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
package nl.utwente.bpsd.selenium;
|
||||||
|
|
||||||
|
import org.junit.After;
|
||||||
|
import org.openqa.selenium.By;
|
||||||
|
import org.openqa.selenium.chrome.ChromeDriver;
|
||||||
|
import org.openqa.selenium.remote.DesiredCapabilities;
|
||||||
|
import org.openqa.selenium.remote.RemoteWebDriver;
|
||||||
|
|
||||||
|
import java.net.MalformedURLException;
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Martijn
|
||||||
|
* @since 21-6-2017.
|
||||||
|
*/
|
||||||
|
public class SeleniumBaseTest {
|
||||||
|
protected final RemoteWebDriver driver;
|
||||||
|
public static final String BASE_URL = "http://pet-clinic:8080/";
|
||||||
|
// public static final String BASE_URL = "http://localhost:8080/";
|
||||||
|
|
||||||
|
public SeleniumBaseTest() throws MalformedURLException {
|
||||||
|
// System.setProperty("webdriver.chrome.driver","C:\\Users\\marti\\Downloads\\chromedriver_win32\\chromedriver.exe");
|
||||||
|
// this.driver = new ChromeDriver();
|
||||||
|
this.driver = new RemoteWebDriver(new URL("http://selenium:4444/wd/hub"), DesiredCapabilities.firefox());
|
||||||
|
driver.get(BASE_URL);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void fillTextField(By by, String text){
|
||||||
|
driver.findElement(by).clear();
|
||||||
|
driver.findElement(by).sendKeys(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
@After
|
||||||
|
public void afterTest() {
|
||||||
|
driver.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected boolean pageContainsText(String text) {
|
||||||
|
return driver.findElementsByXPath("//*[text()='"+text+"']").size() == 1;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue