Skip to content

Commit 7cfaf2d

Browse files
committed
WhenAdminAddCategory.shouldCreateCategoryWithNameInEnglishOnly: port to Robot Framework.
This commit also adds Robot framework to the dependencies. Tests will be running during `mvn verify`. Useful resources: - http://robotframework.org - http://robotframework.or/MavenPlugin/index.html - https://repo1.maven.org/maven2/com/github/markusbernhardt/robotframework-selenium2library-java/1.4.0.8/robotframework-selenium2library-java-1.4.0.8-libdoc.html Addressed to #530 No functional changes.
1 parent 6942bea commit 7cfaf2d

File tree

6 files changed

+141
-13
lines changed

6 files changed

+141
-13
lines changed

pom.xml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,59 @@
264264
<scope>test</scope>
265265
</dependency>
266266

267+
<dependency>
268+
<groupId>com.github.markusbernhardt</groupId>
269+
<artifactId>robotframework-selenium2library-java</artifactId>
270+
<version>${robotframework-selenium.version}</version>
271+
<scope>test</scope>
272+
<exclusions>
273+
<exclusion>
274+
<groupId>org.yaml</groupId>
275+
<artifactId>snakeyaml</artifactId>
276+
</exclusion>
277+
<exclusion>
278+
<groupId>com.github.detro.ghostdriver</groupId>
279+
<artifactId>phantomjsdriver</artifactId>
280+
</exclusion>
281+
<exclusion>
282+
<groupId>com.opera</groupId>
283+
<artifactId>operadriver</artifactId>
284+
</exclusion>
285+
<exclusion>
286+
<groupId>io.appium</groupId>
287+
<artifactId>java-client</artifactId>
288+
</exclusion>
289+
<exclusion>
290+
<groupId>io.selendroid</groupId>
291+
<artifactId>selendroid-client</artifactId>
292+
</exclusion>
293+
<exclusion>
294+
<groupId>org.seleniumhq.selenium</groupId>
295+
<artifactId>selenium-edge-driver</artifactId>
296+
</exclusion>
297+
<exclusion>
298+
<groupId>org.seleniumhq.selenium</groupId>
299+
<artifactId>selenium-chrome-driver</artifactId>
300+
</exclusion>
301+
<exclusion>
302+
<groupId>org.seleniumhq.selenium</groupId>
303+
<artifactId>selenium-ie-driver</artifactId>
304+
</exclusion>
305+
<exclusion>
306+
<groupId>org.seleniumhq.selenium</groupId>
307+
<artifactId>selenium-safari-driver</artifactId>
308+
</exclusion>
309+
<exclusion>
310+
<groupId>org.seleniumhq.selenium</groupId>
311+
<artifactId>selenium-leg-rc</artifactId>
312+
</exclusion>
313+
<exclusion>
314+
<groupId>org.seleniumhq.selenium</groupId>
315+
<artifactId>selenium-firefox-driver</artifactId>
316+
</exclusion>
317+
</exclusions>
318+
</dependency>
319+
267320
<dependency>
268321
<groupId>org.codehaus.groovy</groupId>
269322
<artifactId>groovy-all</artifactId>
@@ -278,6 +331,13 @@
278331
<scope>test</scope>
279332
</dependency>
280333

334+
<dependency>
335+
<groupId>org.robotframework</groupId>
336+
<artifactId>robotframework</artifactId>
337+
<version>${robotframework.version}</version>
338+
<scope>test</scope>
339+
</dependency>
340+
281341
<dependency>
282342
<groupId>org.seleniumhq.selenium</groupId>
283343
<artifactId>htmlunit-driver</artifactId>
@@ -428,6 +488,9 @@
428488
<!-- Dependency can be safely removed when pmd plugin will require this version -->
429489
<pmd.version>5.5.2</pmd.version>
430490
<resources.plugin.version>3.0.2</resources.plugin.version>
491+
<robotframework-plugin.version>1.4.6</robotframework-plugin.version>
492+
<robotframework-selenium.version>1.4.0.8</robotframework-selenium.version>
493+
<robotframework.version>3.0</robotframework.version>
431494

432495
<!-- Don't forget to update version in the Url class -->
433496
<selectizejs.version>0.12.3</selectizejs.version>
@@ -845,6 +908,37 @@
845908
</configuration>
846909
</plugin>
847910

911+
<!--
912+
Usage:
913+
mvn robotframework:run (runs tests and generates report in target/robotframework-reports/report.html)
914+
-->
915+
<plugin>
916+
<groupId>org.robotframework</groupId>
917+
<artifactId>robotframework-maven-plugin</artifactId>
918+
<version>${robotframework-plugin.version}</version>
919+
<configuration>
920+
<testCasesDirectory>${basedir}/src/test/robotframework</testCasesDirectory>
921+
<xunitFile>NONE</xunitFile>
922+
<!-- Handy for debugging. Log file will be created in target/ directory -->
923+
<!--
924+
<debugFile>${project.build.directory}/robotframework.log</debugFile>
925+
<logLevel>DEBUG</logLevel>
926+
-->
927+
<variables>
928+
<variable>BROWSER:htmlunitwithjs</variable>
929+
<!-- See also ru.mystamps.web.Url.SITE constant -->
930+
<variable>SITE_URL:http://127.0.0.1:8080</variable>
931+
</variables>
932+
</configuration>
933+
<executions>
934+
<execution>
935+
<goals>
936+
<goal>run</goal>
937+
</goals>
938+
</execution>
939+
</executions>
940+
</plugin>
941+
848942
<plugin>
849943
<groupId>org.springframework.boot</groupId>
850944
<artifactId>spring-boot-maven-plugin</artifactId>

src/main/java/ru/mystamps/web/Url.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public final class Url {
3131
public static final String PUBLIC_URL = "https://my-stamps.ru";
3232
public static final String STATIC_RESOURCES_URL = "https://stamps.filezz.ru";
3333

34-
// defined at pom.xml (and used by functional tests only)
34+
// see also robotframework-maven-plugin configuration at pom.xml
3535
public static final String SITE = "http://127.0.0.1:8080";
3636

3737
public static final String INDEX_PAGE = "/";

src/main/webapp/WEB-INF/views/category/add.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ <h3 th:text="${#strings.capitalize(create_category)} ">
105105
</small>
106106
</div>
107107

108-
<form method="post" class="form-horizontal" action="info.html" th:action="@{${ADD_CATEGORY_PAGE}}" th:object="${addCategoryForm}">
108+
<form id="add-category-form" method="post" class="form-horizontal" action="info.html"
109+
th:action="@{${ADD_CATEGORY_PAGE}}" th:object="${addCategoryForm}">
109110

110111
<div class="form-group" th:classappend="${#fields.hasErrors('name') ? 'has-error' : ''}">
111112
<label for="name" class="control-label col-sm-4">

src/main/webapp/WEB-INF/views/category/info.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
</div>
9696
<div class="row">
9797
<div id="content" class="col-sm-12">
98-
<h3 th:text="${categoryName}">
98+
<h3 id="page-header" th:text="${categoryName}">
9999
Animals
100100
</h3>
101101

src/test/java/ru/mystamps/web/tests/cases/WhenAdminAddCategory.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -227,16 +227,6 @@ public void categoryNameRuShouldReplaceRepeatedSpacesByOne() {
227227
assertThat(page).field("nameRu").hasValue("т3 ст");
228228
}
229229

230-
@Test(groups = "logic", dependsOnGroups = { "std", "invalid", "valid", "misc" })
231-
public void shouldCreateCategoryWithNameInEnglishOnly() {
232-
page.addCategory("Cars", null);
233-
234-
String expectedUrl = Url.INFO_CATEGORY_PAGE.replace("{slug}", "cars");
235-
236-
assertThat(page.getCurrentUrl()).isEqualTo(expectedUrl);
237-
assertThat(page.getHeader()).isEqualTo("Cars");
238-
}
239-
240230
@Test(groups = "logic", dependsOnGroups = { "std", "invalid", "valid", "misc" })
241231
public void shouldCreateCategoryWithNameInTwoLanguages() {
242232
page.addCategory(TEST_CATEGORY_NAME_EN, TEST_CATEGORY_NAME_RU);
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
*** Settings ***
2+
Documentation Verify category creation scenarios
3+
Library Selenium2Library
4+
Suite Setup Before Test Suite
5+
Suite Teardown After Test Suite
6+
Test Setup Before Test
7+
Force Tags Category
8+
9+
*** Test Cases ***
10+
Create category with name in English
11+
[Documentation] Verify creation of category by filling only mandatory fields
12+
Input Text id=name Cars
13+
Submit Form id=add-category-form
14+
Location Should Be ${SITE_URL}/category/cars
15+
Element Text Should Be id=page-header Cars
16+
17+
*** Keywords ***
18+
Before Test Suite
19+
[Documentation] Open browsers, register fail hook and login as admin
20+
Open Browser ${SITE_URL} ${BROWSER}
21+
Register Keyword To Run On Failure Log Source
22+
Log In As login=admin password=test
23+
24+
Before Test
25+
[Documentation] Open create category page
26+
Go To ${SITE_URL}/category/add
27+
28+
After Test Suite
29+
[Documentation] Log out and closes browser
30+
Log Out
31+
Close Browser
32+
33+
Log In As
34+
[Documentation] Log in as a user
35+
[Arguments] ${login} ${password}
36+
Go To ${SITE_URL}/account/auth
37+
Input Text id=login ${login}
38+
Input Password id=password ${password}
39+
Submit Form id=auth-account-form
40+
41+
Log Out
42+
[Documentation] Log out current user
43+
Submit Form id=logout-form

0 commit comments

Comments
 (0)