Skip to content

Commit 952f81b

Browse files
committed
WhenAnyUserAtAnyPageWithForm(shouldHaveLabels): remove check.
I don't want to port it to the Robot Framework because I'm trying to make tests to test a behavior instead of the pages state. No functional changes.
1 parent 7ea2e86 commit 952f81b

17 files changed

+46
-88
lines changed

src/main/webapp/WEB-INF/views/account/activate.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ <h3 th:text="#{t_activation_on_site}">
123123

124124
<div class="form-group" th:classappend="${#fields.hasErrors('login') ? 'has-error' : ''}">
125125
<label for="login" class="control-label col-sm-3">
126-
<span class="field-label" th:text="#{t_login}">Login</span>
126+
<span th:remove="tag" th:text="#{t_login}">Login</span>
127127
<span id="login.required" class="required_field">*</span>
128128
</label>
129129
<div class="col-sm-5">
@@ -136,7 +136,7 @@ <h3 th:text="#{t_activation_on_site}">
136136

137137
<div class="form-group" th:classappend="${#fields.hasErrors('name') ? 'has-error' : ''}">
138138
<label for="name" class="control-label col-sm-3">
139-
<span class="field-label" th:text="#{t_name}">Name</span>
139+
<span th:remove="tag" th:text="#{t_name}">Name</span>
140140
</label>
141141
<div class="col-sm-5">
142142
<input type="text" id="name" class="form-control" th:field="*{name}" />
@@ -148,7 +148,7 @@ <h3 th:text="#{t_activation_on_site}">
148148

149149
<div class="form-group" th:classappend="${#fields.hasErrors('password') ? 'has-error' : ''}">
150150
<label for="password" class="control-label col-sm-3">
151-
<span class="field-label" th:text="#{t_password}">Password</span>
151+
<span th:remove="tag" th:text="#{t_password}">Password</span>
152152
<span id="password.required" class="required_field">*</span>
153153
</label>
154154
<div class="col-sm-5">
@@ -161,7 +161,7 @@ <h3 th:text="#{t_activation_on_site}">
161161

162162
<div class="form-group" th:classappend="${#fields.hasErrors('passwordConfirmation') ? 'has-error' : ''}">
163163
<label for="passwordConfirmation" class="control-label col-sm-3">
164-
<span class="field-label" th:text="#{t_password_again}">Retype password</span>
164+
<span th:remove="tag" th:text="#{t_password_again}">Retype password</span>
165165
<span id="passwordConfirmation.required" class="required_field">*</span>
166166
</label>
167167
<div class="col-sm-5">
@@ -174,7 +174,7 @@ <h3 th:text="#{t_activation_on_site}">
174174

175175
<div class="form-group" th:classappend="${#fields.hasErrors('activationKey') ? 'has-error' : ''}">
176176
<label for="activationKey" class="control-label col-sm-3">
177-
<span class="field-label" th:text="#{t_activation_key}">Activation key</span>
177+
<span th:remove="tag" th:text="#{t_activation_key}">Activation key</span>
178178
<span id="activationKey.required" class="required_field">*</span>
179179
</label>
180180
<div class="col-sm-5">

src/main/webapp/WEB-INF/views/account/auth.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ <h3 th:text="#{t_authentication_on_site}">
127127

128128
<div class="form-group">
129129
<label for="login" class="control-label col-sm-4">
130-
<span class="field-label" th:text="#{t_login}">Login</span>
130+
<span th:remove="tag" th:text="#{t_login}">Login</span>
131131
<span id="login.required" class="required_field">*</span>
132132
</label>
133133
<div class="col-sm-4">
@@ -137,7 +137,7 @@ <h3 th:text="#{t_authentication_on_site}">
137137

138138
<div class="form-group">
139139
<label for="password" class="control-label col-sm-4">
140-
<span class="field-label" th:text="#{t_password}">Password</span>
140+
<span th:remove="tag" th:text="#{t_password}">Password</span>
141141
<span id="password.required" class="required_field">*</span>
142142
</label>
143143
<div class="col-sm-4">

src/main/webapp/WEB-INF/views/account/register.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ <h3 th:text="#{t_registration_on_site}">
115115

116116
<div class="form-group" th:classappend="${#fields.hasErrors('email') ? 'has-error' : ''}">
117117
<label class="control-label col-sm-4" for="email">
118-
<span class="field-label" th:text="#{t_email}">E-mail</span>
118+
<span th:remove="tag" th:text="#{t_email}">E-mail</span>
119119
<span id="email.required" class="required_field">*</span>
120120
</label>
121121
<div class="col-sm-5">

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ <h3 th:text="${#strings.capitalize(create_category)} ">
110110

111111
<div class="form-group" th:classappend="${#fields.hasErrors('name') ? 'has-error' : ''}">
112112
<label for="name" class="control-label col-sm-4">
113-
<span class="field-label" th:text="#{t_name_in_english}">
113+
<span th:remove="tag" th:text="#{t_name_in_english}">
114114
Name (in English)
115115
</span>
116116
<span id="name.required" class="required_field">*</span>
@@ -125,7 +125,7 @@ <h3 th:text="${#strings.capitalize(create_category)} ">
125125

126126
<div class="form-group" th:classappend="${#fields.hasErrors('nameRu') ? 'has-error' : ''}">
127127
<label for="nameRu" class="control-label col-sm-4">
128-
<span class="field-label" th:text="#{t_name_in_russian}">
128+
<span th:remove="tag" th:text="#{t_name_in_russian}">
129129
Name (in Russian)
130130
</span>
131131
</label>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ <h3 th:text="${#strings.capitalize(add_country)}">
110110

111111
<div class="form-group" th:classappend="${#fields.hasErrors('name') ? 'has-error' : ''}">
112112
<label for="name" class="control-label col-sm-4">
113-
<span class="field-label" th:text="#{t_name_in_english}">
113+
<span th:remove="tag" th:text="#{t_name_in_english}">
114114
Name (in English)
115115
</span>
116116
<span id="name.required" class="required_field">*</span>
@@ -125,7 +125,7 @@ <h3 th:text="${#strings.capitalize(add_country)}">
125125

126126
<div class="form-group" th:classappend="${#fields.hasErrors('nameRu') ? 'has-error' : ''}">
127127
<label for="nameRu" class="control-label col-sm-4">
128-
<span class="field-label" th:text="#{t_name_in_russian}">
128+
<span th:remove="tag" th:text="#{t_name_in_russian}">
129129
Name (in Russian)
130130
</span>
131131
</label>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ <h3 th:text="${#strings.capitalize(header)} ">
110110

111111
<div class="form-group" th:classappend="${#fields.hasErrors('name') ? 'has-error' : ''}">
112112
<label for="name" class="control-label col-sm-4">
113-
<span class="field-label" th:text="#{t_name}">
113+
<span th:remove="tag" th:text="#{t_name}">
114114
Name
115115
</span>
116116
<span id="name.required" class="required_field">*</span>
@@ -125,7 +125,7 @@ <h3 th:text="${#strings.capitalize(header)} ">
125125

126126
<div class="form-group" th:classappend="${#fields.hasErrors('url') ? 'has-error' : ''}">
127127
<label for="url" class="control-label col-sm-4">
128-
<span class="field-label" th:text="#{t_url}">
128+
<span th:remove="tag" th:text="#{t_url}">
129129
URL
130130
</span>
131131
</label>

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ <h3 th:text="${#strings.capitalize(add_series)}">
129129

130130
<div class="form-group form-group-sm" th:classappend="${#fields.hasErrors('category') ? 'has-error' : ''}">
131131
<label for="category" class="control-label col-sm-3">
132-
<span class="field-label" th:text="#{t_category}">
132+
<span th:remove="tag" th:text="#{t_category}">
133133
Category
134134
</span>
135135
<span id="category.required" class="required_field">*</span>
@@ -173,7 +173,7 @@ <h3 th:text="${#strings.capitalize(add_series)}">
173173

174174
<div class="form-group form-group-sm" th:classappend="${#fields.hasErrors('country') ? 'has-error' : ''}">
175175
<label for="country" class="control-label col-sm-3">
176-
<span class="field-label" th:text="#{t_country}">
176+
<span th:remove="tag" th:text="#{t_country}">
177177
Country
178178
</span>
179179
</label>
@@ -210,7 +210,7 @@ <h3 th:text="${#strings.capitalize(add_series)}">
210210

211211
<div class="form-group form-group-sm" th:classappend="${#fields.hasErrors('quantity') ? 'has-error' : ''}">
212212
<label for="quantity" class="control-label col-sm-3">
213-
<span class="field-label" th:text="#{t_quantity}">
213+
<span th:remove="tag" th:text="#{t_quantity}">
214214
Quantity
215215
</span>
216216
<span id="quantity.required" class="required_field">*</span>
@@ -245,7 +245,7 @@ <h3 th:text="${#strings.capitalize(add_series)}">
245245

246246
<div class="form-group form-group-sm" th:classappend="${#fields.hasErrors('perforated') ? 'has-error' : ''}">
247247
<label for="perforated" class="control-label col-sm-3">
248-
<span class="field-label" th:text="#{t_perforated}">
248+
<span th:remove="tag" th:text="#{t_perforated}">
249249
Perforated
250250
</span>
251251
</label>
@@ -259,7 +259,7 @@ <h3 th:text="${#strings.capitalize(add_series)}">
259259

260260
<div class="form-group form-group-sm" th:classappend="${#fields.hasErrors('image') ? 'has-error' : ''}">
261261
<label for="image" class="control-label col-sm-3">
262-
<span class="field-label" th:text="#{t_image}">
262+
<span th:remove="tag" th:text="#{t_image}">
263263
Image
264264
</span>
265265
<span id="image.required" class="required_field">*</span>
@@ -285,7 +285,7 @@ <h3 th:text="${#strings.capitalize(add_series)}">
285285

286286
<div class="form-group form-group-sm collapse js-issue-date" th:classappend="|${issueDateHasErrors ? 'has-error in' : ''} ${issueDateHasValues ? 'in' : ''}|">
287287
<label for="year" class="control-label col-sm-3">
288-
<span class="field-label" th:text="#{t_issue_date}">
288+
<span th:remove="tag" th:text="#{t_issue_date}">
289289
Date of release
290290
</span>
291291
</label>
@@ -377,7 +377,7 @@ <h3 th:text="${#strings.capitalize(add_series)}">
377377

378378
<div class="form-group form-group-sm collapse js-catalogs-info" th:classappend="|${michelHasErrors ? 'has-error' : ''} ${showCatalogsInfo ? 'in' : ''}|">
379379
<label for="michelNumbers" class="control-label col-sm-3">
380-
<span class="field-label" th:text="#{t_michel}">
380+
<span th:remove="tag" th:text="#{t_michel}">
381381
Michel
382382
</span>
383383
</label>
@@ -402,7 +402,7 @@ <h3 th:text="${#strings.capitalize(add_series)}">
402402

403403
<div class="form-group form-group-sm collapse js-catalogs-info" th:classappend="|${scottHasErrors ? 'has-error' : ''} ${showCatalogsInfo ? 'in' : ''}|">
404404
<label for="scottNumbers" class="control-label col-sm-3">
405-
<span class="field-label" th:text="#{t_scott}">
405+
<span th:remove="tag" th:text="#{t_scott}">
406406
Scott
407407
</span>
408408
</label>
@@ -427,7 +427,7 @@ <h3 th:text="${#strings.capitalize(add_series)}">
427427

428428
<div class="form-group form-group-sm collapse js-catalogs-info" th:classappend="|${yvertHasErrors ? 'has-error' : ''} ${showCatalogsInfo ? 'in' : ''}|">
429429
<label for="yvertNumbers" class="control-label col-sm-3">
430-
<span class="field-label" th:text="#{t_yvert}">
430+
<span th:remove="tag" th:text="#{t_yvert}">
431431
Yvert
432432
</span>
433433
</label>
@@ -452,7 +452,7 @@ <h3 th:text="${#strings.capitalize(add_series)}">
452452

453453
<div class="form-group form-group-sm collapse js-catalogs-info" th:classappend="|${gibbonsHasErrors ? 'has-error' : ''} ${showCatalogsInfo ? 'in' : ''}|">
454454
<label for="gibbonsNumbers" class="control-label col-sm-3">
455-
<span class="field-label" th:text="#{t_sg}">
455+
<span th:remove="tag" th:text="#{t_sg}">
456456
Gibbons
457457
</span>
458458
</label>
@@ -483,7 +483,7 @@ <h3 th:text="${#strings.capitalize(add_series)}">
483483

484484
<div class="form-group collapse js-comment" th:classappend="|${#fields.hasErrors('comment') ? 'has-error in' : ''} ${addSeriesForm.comment != null ? 'in' : ''}|" sec:authorize="hasAuthority('ADD_COMMENTS_TO_SERIES')">
485485
<label for="comment" class="control-label col-sm-3">
486-
<span class="field-label" th:text="#{t_comment}">
486+
<span th:remove="tag" th:text="#{t_comment}">
487487
Comment
488488
</span>
489489
</label>

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ <h5 th:text="|#{t_add_info_who_selling_series}:|">Add info about selling/buying
370370

371371
<div class="form-group form-group-sm" th:classappend="${#fields.hasErrors('date') ? 'has-error' : ''}">
372372
<label for="date" class="control-label col-sm-3">
373-
<span class="field-label" th:text="#{t_date}">
373+
<span th:remove="tag" th:text="#{t_date}">
374374
Date
375375
</span>
376376
</label>
@@ -384,7 +384,7 @@ <h5 th:text="|#{t_add_info_who_selling_series}:|">Add info about selling/buying
384384

385385
<div class="form-group form-group-sm" th:classappend="${#fields.hasErrors('sellerId') ? 'has-error' : ''}">
386386
<label for="seller" class="control-label col-sm-3">
387-
<span class="field-label" th:text="#{t_seller}">
387+
<span th:remove="tag" th:text="#{t_seller}">
388388
Seller
389389
</span>
390390
<span id="seller.required" class="required_field">*</span>
@@ -414,7 +414,7 @@ <h5 th:text="|#{t_add_info_who_selling_series}:|">Add info about selling/buying
414414

415415
<div class="form-group form-group-sm" th:classappend="${#fields.hasErrors('url') ? 'has-error' : ''}">
416416
<label for="url" class="control-label col-sm-3">
417-
<span class="field-label" th:text="#{t_url}">
417+
<span th:remove="tag" th:text="#{t_url}">
418418
URL
419419
</span>
420420
</label>
@@ -428,7 +428,7 @@ <h5 th:text="|#{t_add_info_who_selling_series}:|">Add info about selling/buying
428428

429429
<div class="form-group form-group-sm" th:classappend="${#fields.hasErrors('price') or #fields.hasErrors('currency') ? 'has-error' : ''}">
430430
<label for="price" class="control-label col-sm-3">
431-
<span class="field-label" th:text="#{t_price}">
431+
<span th:remove="tag" th:text="#{t_price}">
432432
Price
433433
</span>
434434
<span id="price.required" class="required_field">*</span>
@@ -456,7 +456,7 @@ <h5 th:text="|#{t_add_info_who_selling_series}:|">Add info about selling/buying
456456

457457
<div class="form-group form-group-sm" th:classappend="${#fields.hasErrors('altPrice') or #fields.hasErrors('altCurrency') ? 'has-error' : ''}">
458458
<label for="price" class="control-label col-sm-3">
459-
<span class="field-label" th:text="#{t_alternative_price}">
459+
<span th:remove="tag" th:text="#{t_alternative_price}">
460460
Alternative price
461461
</span>
462462
</label>
@@ -483,7 +483,7 @@ <h5 th:text="|#{t_add_info_who_selling_series}:|">Add info about selling/buying
483483

484484
<div class="form-group form-group-sm" th:classappend="${#fields.hasErrors('buyerId') ? 'has-error' : ''}">
485485
<label for="buyer" class="control-label col-sm-3">
486-
<span class="field-label" th:text="#{t_buyer}">
486+
<span th:remove="tag" th:text="#{t_buyer}">
487487
Buyer
488488
</span>
489489
</label>

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

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ abstract class WhenAnyUserAtAnyPageWithForm<T extends AbstractPageWithForm>
3737

3838
protected void checkStandardStructure() {
3939
shouldHaveFields();
40-
shouldHaveLabels();
4140
shouldHaveSubmitButton();
4241

4342
requiredFieldsShouldBeMarkedByAsterisk();
@@ -57,24 +56,6 @@ private void shouldHaveFields() {
5756
}
5857
}
5958

60-
private void shouldHaveLabels() {
61-
for (Field field : page.getForm().getFields()) {
62-
if (!field.isAccessibleByAll() || !field.hasLabel()) {
63-
continue;
64-
}
65-
66-
String msg = String.format(
67-
"field with id '%s' should have label '%s'",
68-
field.getId(),
69-
field.getLabel()
70-
);
71-
72-
assertThat(page.getInputLabelValue(field.getId()))
73-
.overridingErrorMessage(msg)
74-
.isEqualTo(field.getLabel());
75-
}
76-
}
77-
7859
private void shouldHaveSubmitButton() {
7960
for (SubmitButton button : page.getForm().getSubmitButtons()) {
8061
assertThat(page.isSubmitButtonExists(button))

src/test/java/ru/mystamps/web/tests/page/AbstractPageWithForm.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@
3434

3535
public abstract class AbstractPageWithForm extends AbstractPage {
3636

37-
// CheckStyle: ignore LineLength for next 1 line
38-
private static final String LABEL_LOCATOR = "//label[@for=\"%s\"]/span[@class=\"field-label\"]";
3937
private static final String FIELD_ERROR_LOCATOR = "//span[@id=\"%s.errors\"]";
4038
private static final String FIELD_REQUIRED_LOCATOR = "//span[@id=\"%s.required\"]";
4139
private static final String FORM_ERROR_LOCATOR = "//div[@id=\"form.errors\"]";
@@ -87,10 +85,6 @@ public AbstractPage submit() {
8785
return this;
8886
}
8987

90-
public String getInputLabelValue(String id) {
91-
return getTextOfElementByXPath(String.format(LABEL_LOCATOR, id));
92-
}
93-
9488
public boolean inputHasAsterisk(String id) {
9589
try {
9690
String requiredFieldMark =

src/test/java/ru/mystamps/web/tests/page/ActivateAccountPage.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,27 +38,22 @@ public ActivateAccountPage(WebDriver driver) {
3838
hasForm(
3939
with(
4040
required(inputField("login"))
41-
.withLabel(tr("t_login"))
4241
.and().
4342
invalidValue("x"),
4443

4544
inputField("name")
46-
.withLabel(tr("t_name"))
4745
.and()
4846
.invalidValue("x"),
4947

5048
required(passwordField("password"))
51-
.withLabel(tr("t_password"))
5249
.and()
5350
.invalidValue("x"),
5451

5552
required(passwordField("passwordConfirmation"))
56-
.withLabel(tr("t_password_again"))
5753
.and()
5854
.invalidValue("x"),
5955

6056
required(inputField("activationKey"))
61-
.withLabel(tr("t_activation_key"))
6257
.and()
6358
.invalidValue("x")
6459
)

src/test/java/ru/mystamps/web/tests/page/AddCategoryPage.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ public AddCategoryPage(WebDriver driver) {
3636

3737
hasForm(
3838
with(
39-
required(inputField("name")).withLabel(tr("t_category_on_english")),
40-
inputField("nameRu").withLabel(tr("t_category_on_russian"))
39+
required(inputField("name")),
40+
inputField("nameRu")
4141
)
4242
.and()
4343
.with(submitButton(tr("t_add")))

src/test/java/ru/mystamps/web/tests/page/AddCountryPage.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ public AddCountryPage(WebDriver driver) {
3636

3737
hasForm(
3838
with(
39-
required(inputField("name")).withLabel(tr("t_country_on_english")),
40-
inputField("nameRu").withLabel(tr("t_country_on_russian"))
39+
required(inputField("name")),
40+
inputField("nameRu")
4141
)
4242
.and()
4343
.with(submitButton(tr("t_add")))

0 commit comments

Comments
 (0)