File tree 3 files changed +57
-3
lines changed
step_definition/templates/ui
3 files changed +57
-3
lines changed Original file line number Diff line number Diff line change 1
- package step_definition .templates .ui ;public class BrokenImagesStepDefinition {
1
+ package step_definition .templates .ui ;
2
+
3
+ import io .cucumber .java .en .Then ;
4
+ import io .cucumber .java .en .When ;
5
+ import org .openqa .selenium .By ;
6
+ import org .openqa .selenium .WebElement ;
7
+
8
+ import static modules .Hooks .driver ;
9
+ import static org .junit .Assert .assertTrue ;
10
+ import static utils .Images .*;
11
+
12
+ public class BrokenImagesStepDefinition {
13
+ WebElement image ;
14
+ @ When ("image {int}" )
15
+ public void imageImageIndex (int index ) {
16
+ image = driver .findElement (By .cssSelector ("#content > div > img:nth-child(" +index +")" ));
17
+ }
18
+
19
+ @ Then ("if broken test should fail" )
20
+ public void ifBrokenTestShouldFail () {
21
+ assertTrue (!isImageBroken (image ));
22
+ }
2
23
}
Original file line number Diff line number Diff line change 1
- package step_definition .templates .ui ;public class CheckboxesStepDefinition {
1
+ package step_definition .templates .ui ;
2
+
3
+ import io .cucumber .java .en .Then ;
4
+ import io .cucumber .java .en .When ;
5
+ import org .openqa .selenium .By ;
6
+ import org .openqa .selenium .WebElement ;
7
+
8
+ import static modules .Hooks .driver ;
9
+ import static org .junit .Assert .*;
10
+
11
+ public class CheckboxesStepDefinition {
12
+ WebElement checkbox ;
13
+
14
+ @ When ("user checks box {int}" )
15
+ public void userChecksBox (int arg0 ) {
16
+ checkbox = driver .findElement (By .cssSelector ("#checkboxes > input[type=checkbox]:nth-child(" +arg0 +")" ));
17
+ if (!checkbox .isSelected ()) {
18
+ checkbox .click ();
19
+ }
20
+ }
21
+
22
+ @ Then ("checkbox {int} is checked" )
23
+ public void checkboxIsChecked (int arg0 ) {
24
+ checkbox = driver .findElement (By .cssSelector ("#checkboxes > input[type=checkbox]:nth-child(" +arg0 +")" ));
25
+ assertTrue (checkbox .isSelected ());
26
+ }
2
27
}
Original file line number Diff line number Diff line change 1
- package utils ;public class Images {
1
+ package utils ;
2
+
3
+ import org .openqa .selenium .WebElement ;
4
+
5
+ public class Images {
6
+
7
+ public static boolean isImageBroken (WebElement image ) {
8
+ return image .getAttribute ("naturalWidth" ).equals ("0" );
9
+ }
2
10
}
You can’t perform that action at this time.
0 commit comments