Skip to content

Instantly share code, notes, and snippets.

@Anass-ABEA
Last active December 11, 2021 18:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Anass-ABEA/d107c0b37492a2446baa649e7c5885a9 to your computer and use it in GitHub Desktop.
Save Anass-ABEA/d107c0b37492a2446baa649e7c5885a9 to your computer and use it in GitHub Desktop.
Fichiers modifiés pendants les tests fonctionnels Selenium
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.springframework.samples</groupId>
<artifactId>spring-petclinic</artifactId>
<version>2.5.0-SNAPSHOT</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.6</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>5.1.3</webjars-bootstrap.version>
<webjars-font-awesome.version>4.7.0</webjars-font-awesome.version>
<jacoco.version>0.8.5</jacoco.version>
<node.version>v8.11.1</node.version>
<nohttp-checkstyle.version>0.0.4.RELEASE</nohttp-checkstyle.version>
<spring-format.version>0.0.27</spring-format.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-validation</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- Databases - Uses H2 by default -->
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</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-core</artifactId>
</dependency>
<dependency>
<groupId>org.webjars.npm</groupId>
<artifactId>bootstrap</artifactId>
<version>${webjars-bootstrap.version}</version>
</dependency>
<dependency>
<groupId>org.webjars.npm</groupId>
<artifactId>font-awesome</artifactId>
<version>${webjars-font-awesome.version}</version>
</dependency>
<!-- end of webjars -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.9.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>io.spring.javaformat</groupId>
<artifactId>spring-javaformat-maven-plugin</artifactId>
<version>${spring-format.version}</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>validate</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.1.1</version>
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>8.32</version>
</dependency>
<dependency>
<groupId>io.spring.nohttp</groupId>
<artifactId>nohttp-checkstyle</artifactId>
<version>${nohttp-checkstyle.version}</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>nohttp-checkstyle-validation</id>
<phase>validate</phase>
<configuration>
<configLocation>src/checkstyle/nohttp-checkstyle.xml</configLocation>
<suppressionsLocation>src/checkstyle/nohttp-checkstyle-suppressions.xml</suppressionsLocation>
<encoding>UTF-8</encoding>
<sourceDirectories>${basedir}</sourceDirectories>
<includes>**/*</includes>
<excludes>**/.git/**/*,**/.idea/**/*,**/target/**/,**/.flattened-pom.xml,**/*.class</excludes>
</configuration>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<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.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.version}</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</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>
<failOnUnableToExtractRepoInfo>false</failOnUnableToExtractRepoInfo>
</configuration>
</plugin>
</plugins>
</build>
<licenses>
<license>
<name>Apache License, Version 2.0</name>
<url>https://www.apache.org/licenses/LICENSE-2.0</url>
</license>
</licenses>
<repositories>
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
<profiles>
<profile>
<id>css</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack</id>
<?m2e execute onConfiguration,onIncremental?>
<phase>generate-resources</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.webjars.npm</groupId>
<artifactId>bootstrap</artifactId>
<version>${webjars-bootstrap.version}</version>
</artifactItem>
</artifactItems>
<outputDirectory>${project.build.directory}/webjars</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.gitlab.haynes</groupId>
<artifactId>libsass-maven-plugin</artifactId>
<version>0.2.26</version>
<executions>
<execution>
<phase>generate-resources</phase>
<?m2e execute onConfiguration,onIncremental?>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
<configuration>
<inputPath>${basedir}/src/main/scss/</inputPath>
<outputPath>${basedir}/src/main/resources/static/resources/css/</outputPath>
<includePath>${project.build.directory}/webjars/META-INF/resources/webjars/bootstrap/${webjars-bootstrap.version}/scss/</includePath>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>m2e</id>
<activation>
<property>
<name>m2e.version</name>
</property>
</activation>
<build>
<pluginManagement>
<plugins>
<!-- This plugin's configuration is used to store Eclipse m2e settings
only. It has no influence on the Maven build itself. -->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<versionRange>[1,)</versionRange>
<goals>
<goal>check</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore/>
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<versionRange>[1,)</versionRange>
<goals>
<goal>build-info</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore/>
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>io.spring.javaformat</groupId>
<artifactId>spring-javaformat-maven-plugin</artifactId>
<versionRange>[0,)</versionRange>
<goals>
<goal>validate</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore/>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>
</profiles>
</project>
{
"id": "811f62b9-2ecc-47aa-80ed-85ede2b2dc04",
"version": "2.0",
"name": "Pet-Clinic",
"url": "http://localhost:8080",
"tests": [{
"id": "ad7391a7-e130-416d-b287-275c102fdee0",
"name": "Test d'existence d'un pet owner",
"commands": [{
"id": "03fb15f2-ed0a-4611-acef-53ec0a57037e",
"comment": "",
"command": "open",
"target": "/",
"targets": [],
"value": ""
}, {
"id": "a6529727-f417-4ff7-8ac0-3d58fba627cf",
"comment": "",
"command": "setWindowSize",
"target": "1552x840",
"targets": [],
"value": ""
}, {
"id": "cc8bd322-8536-4e29-a9ee-f3e2539e3170",
"comment": "",
"command": "click",
"target": "css=.nav-item:nth-child(2) span:nth-child(2)",
"targets": [
["css=.nav-item:nth-child(2) span:nth-child(2)", "css:finder"],
["xpath=//div[@id='main-navbar']/ul/li[2]/a/span[2]", "xpath:idRelative"],
["xpath=//li[2]/a/span[2]", "xpath:position"]
],
"value": ""
}, {
"id": "73f940cb-b781-43f9-be69-32cecb7c1393",
"comment": "",
"command": "click",
"target": "id=lastName",
"targets": [
["id=lastName", "id"],
["name=lastName", "name"],
["css=#lastName", "css:finder"],
["xpath=//input[@id='lastName']", "xpath:attributes"],
["xpath=//div[@id='lastNameGroup']/div/input", "xpath:idRelative"],
["xpath=//input", "xpath:position"]
],
"value": ""
}, {
"id": "92d5a64a-245a-467d-9021-cff3c7ff62d9",
"comment": "",
"command": "type",
"target": "id=lastName",
"targets": [
["id=lastName", "id"],
["name=lastName", "name"],
["css=#lastName", "css:finder"],
["xpath=//input[@id='lastName']", "xpath:attributes"],
["xpath=//div[@id='lastNameGroup']/div/input", "xpath:idRelative"],
["xpath=//input", "xpath:position"]
],
"value": "Davis"
}, {
"id": "3ff2bcc6-1dac-471d-8d2a-9fce3f052ead",
"comment": "",
"command": "click",
"target": "css=.btn:nth-child(1)",
"targets": [
["css=.btn:nth-child(1)", "css:finder"],
["xpath=//button[@type='submit']", "xpath:attributes"],
["xpath=//form[@id='search-owner-form']/div[2]/div/button", "xpath:idRelative"],
["xpath=//div[2]/div/button", "xpath:position"]
],
"value": ""
}, {
"id": "d68d4bdb-5958-4940-8dd5-a902abfca009",
"comment": "",
"command": "click",
"target": "linkText=Betty Davis",
"targets": [
["linkText=Betty Davis", "linkText"],
["css=tr:nth-child(1) a", "css:finder"],
["xpath=//a[contains(text(),'Betty Davis')]", "xpath:link"],
["xpath=//table[@id='owners']/tbody/tr/td/a", "xpath:idRelative"],
["xpath=//a[contains(@href, '/owners/2')]", "xpath:href"],
["xpath=//td/a", "xpath:position"],
["xpath=//a[contains(.,'Betty Davis')]", "xpath:innerText"]
],
"value": ""
}, {
"id": "09db0371-2f9e-4593-9a10-9b1794e07fc6",
"comment": "",
"command": "assertText",
"target": "css=tr:nth-child(1) > td",
"targets": [],
"value": "Betty Davis"
}, {
"id": "02b541e0-7533-404f-bb1f-abb5799d652c",
"comment": "",
"command": "assertText",
"target": "css=tr:nth-child(2) > td",
"targets": [
["css=tr:nth-child(2) > td", "css:finder"],
["xpath=//tr[2]/td", "xpath:position"],
["xpath=//td[contains(.,'638 Cardinal Ave.')]", "xpath:innerText"]
],
"value": "638 Cardinal Ave."
}, {
"id": "4f837864-9b54-4d4f-b575-778c2ddd7ef7",
"comment": "",
"command": "assertText",
"target": "css=tr:nth-child(3) > td",
"targets": [],
"value": "Sun Prairie"
}, {
"id": "0d9bdcf2-aeda-4eae-8989-664212487085",
"comment": "",
"command": "assertText",
"target": "css=tr:nth-child(4) > td",
"targets": [],
"value": "6085551749"
}]
}, {
"id": "980d3ce7-0b9a-489a-a2c4-7f37fc56377b",
"name": "Test d'existence d'un pet owner - échoue",
"commands": [{
"id": "8cc3400f-b6c9-4f43-92c5-3799d86e6b9b",
"comment": "",
"command": "open",
"target": "/",
"targets": [],
"value": ""
}, {
"id": "a459f2c3-8d7d-460b-98ac-5c1f45b51ae8",
"comment": "",
"command": "setWindowSize",
"target": "1552x840",
"targets": [],
"value": ""
}, {
"id": "cb5e0d0b-1144-49d3-a9ef-2ff349a9e228",
"comment": "",
"command": "click",
"target": "css=.nav-item:nth-child(2) span:nth-child(2)",
"targets": [
["css=.nav-item:nth-child(2) span:nth-child(2)", "css:finder"],
["xpath=//div[@id='main-navbar']/ul/li[2]/a/span[2]", "xpath:idRelative"],
["xpath=//li[2]/a/span[2]", "xpath:position"]
],
"value": ""
}, {
"id": "56322959-215b-4dc2-ad2f-a06660bbfbe8",
"comment": "",
"command": "click",
"target": "id=lastName",
"targets": [
["id=lastName", "id"],
["name=lastName", "name"],
["css=#lastName", "css:finder"],
["xpath=//input[@id='lastName']", "xpath:attributes"],
["xpath=//div[@id='lastNameGroup']/div/input", "xpath:idRelative"],
["xpath=//input", "xpath:position"]
],
"value": ""
}, {
"id": "2049f24f-28e7-4291-8e92-a12d8e242011",
"comment": "",
"command": "type",
"target": "id=lastName",
"targets": [
["id=lastName", "id"],
["name=lastName", "name"],
["css=#lastName", "css:finder"],
["xpath=//input[@id='lastName']", "xpath:attributes"],
["xpath=//div[@id='lastNameGroup']/div/input", "xpath:idRelative"],
["xpath=//input", "xpath:position"]
],
"value": "Coleman"
}, {
"id": "7f341d51-f64f-433a-98c6-364e345655e6",
"comment": "",
"command": "click",
"target": "css=.btn:nth-child(1)",
"targets": [
["css=.btn:nth-child(1)", "css:finder"],
["xpath=//button[@type='submit']", "xpath:attributes"],
["xpath=//form[@id='search-owner-form']/div[2]/div/button", "xpath:idRelative"],
["xpath=//div[2]/div/button", "xpath:position"]
],
"value": ""
}, {
"id": "9d87f9a3-4015-4f77-b8e7-9c79c6b6b676",
"comment": "",
"command": "click",
"target": "linkText=Betty Davis",
"targets": [
["linkText=Betty Davis", "linkText"],
["css=tr:nth-child(1) a", "css:finder"],
["xpath=//a[contains(text(),'Betty Davis')]", "xpath:link"],
["xpath=//table[@id='owners']/tbody/tr/td/a", "xpath:idRelative"],
["xpath=//a[contains(@href, '/owners/2')]", "xpath:href"],
["xpath=//td/a", "xpath:position"],
["xpath=//a[contains(.,'Betty Davis')]", "xpath:innerText"]
],
"value": ""
}, {
"id": "045be75e-500b-42a1-bf5a-3f50fe26cb30",
"comment": "",
"command": "assertText",
"target": "css=tr:nth-child(1) > td",
"targets": [],
"value": "Betty Davis"
}, {
"id": "7310d990-03c5-4ebe-a650-19cc6777039f",
"comment": "",
"command": "assertText",
"target": "css=tr:nth-child(2) > td",
"targets": [
["css=tr:nth-child(2) > td", "css:finder"],
["xpath=//tr[2]/td", "xpath:position"],
["xpath=//td[contains(.,'638 Cardinal Ave.')]", "xpath:innerText"]
],
"value": "638 Cardinal Ave."
}, {
"id": "d5b2a3b3-1101-4de7-8513-ec7607acebaf",
"comment": "",
"command": "assertText",
"target": "css=tr:nth-child(3) > td",
"targets": [],
"value": "Sun Prairie"
}, {
"id": "c9c78bac-ebe3-4371-bd32-ae1da40edb8a",
"comment": "",
"command": "assertText",
"target": "css=tr:nth-child(4) > td",
"targets": [],
"value": "6085551749"
}]
}],
"suites": [{
"id": "719e8cf3-377c-4fe8-bb86-03d8e15bab85",
"name": "Default Suite",
"persistSession": false,
"parallel": false,
"timeout": 300,
"tests": []
}],
"urls": ["http://localhost:8080/"],
"plugins": []
}
package org.springframework.samples.petclinic;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
public class TestExistanceOwnerEchoue {
private WebDriver driver;
@Before
public void setUp() {
System.setProperty("webdriver.chrome.driver", "C:/chromedriver.exe");
driver = new ChromeDriver();
}
@After
public void tearDown() {
driver.quit();
}
@Test
public void testdexistencedunpetownerchoue() {
driver.get("http://localhost:8080/");
driver.manage().window().setSize(new Dimension(1552, 840));
driver.findElement(By.cssSelector(".nav-item:nth-child(2) span:nth-child(2)")).click();
driver.findElement(By.id("lastName")).click();
driver.findElement(By.id("lastName")).sendKeys("Coleman");
driver.findElement(By.cssSelector(".btn:nth-child(1)")).click();
driver.findElement(By.linkText("Betty Davis")).click();
assertThat(driver.findElement(By.cssSelector("tr:nth-child(1) > td")).getText(), is("Betty Davis"));
assertThat(driver.findElement(By.cssSelector("tr:nth-child(2) > td")).getText(), is("638 Cardinal Ave."));
assertThat(driver.findElement(By.cssSelector("tr:nth-child(3) > td")).getText(), is("Sun Prairie"));
assertThat(driver.findElement(By.cssSelector("tr:nth-child(4) > td")).getText(), is("6085551749"));
}
}
package org.springframework.samples.petclinic;
import org.junit.Test;
import org.junit.Before;
import org.junit.After;
import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.is;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.Dimension;
public class TestExistencePetOwnerTest {
private WebDriver driver;
@Before
public void setUp() {
System.setProperty("webdriver.chrome.driver", "C:/chromedriver.exe");
driver = new ChromeDriver();
}
@After
public void tearDown() {
driver.quit();
}
@Test
public void testdexistencedunpetowner() {
driver.get("http://localhost:8080/");
driver.manage().window().setSize(new Dimension(1552, 840));
driver.findElement(By.cssSelector(".nav-item:nth-child(2) span:nth-child(2)")).click();
driver.findElement(By.id("lastName")).click();
driver.findElement(By.id("lastName")).sendKeys("Davis");
driver.findElement(By.cssSelector(".btn:nth-child(1)")).click();
driver.findElement(By.linkText("Betty Davis")).click();
assertThat(driver.findElement(By.cssSelector("tr:nth-child(1) > td")).getText(), is("Betty Davis"));
assertThat(driver.findElement(By.cssSelector("tr:nth-child(2) > td")).getText(), is("638 Cardinal Ave."));
assertThat(driver.findElement(By.cssSelector("tr:nth-child(3) > td")).getText(), is("Sun Prairie"));
assertThat(driver.findElement(By.cssSelector("tr:nth-child(4) > td")).getText(), is("6085551749"));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment