8
8
import org .openqa .selenium .chrome .ChromeDriver ;
9
9
import java .time .Duration ;
10
10
import static org .junit .jupiter .api .Assertions .assertEquals ;
11
+ import static org .junit .jupiter .api .Assertions .assertTrue ;
11
12
12
13
public class InformationTest {
13
14
14
15
@ Test
15
16
public void informationWithElements () {
16
-
17
+
17
18
WebDriver driver = new ChromeDriver ();
18
- driver .manage ().timeouts ().implicitlyWait (Duration .ofMillis (500 ));
19
- // Navigate to Url
20
- driver .get ("https://www.selenium.dev/selenium/web/inputs.html" );
21
-
22
- // isDisplayed
23
- // Get boolean value for is element display
24
- boolean isEmailVisible = driver .findElement (By .name ("email_input" )).isDisplayed ();
25
- assertEquals (isEmailVisible ,true );
26
-
27
- // isEnabled
28
- // returns true if element is enabled else returns false
29
- boolean isEnabledButton = driver .findElement (By .name ("button_input" )).isEnabled ();
30
- assertEquals (isEnabledButton ,true );
31
-
32
- // isSelected
33
- // returns true if element is checked else returns false
34
- boolean isSelectedCheck = driver .findElement (By .name ("checkbox_input" )).isSelected ();
35
- assertEquals (isSelectedCheck ,true );
36
-
37
- // TagName
38
- // returns TagName of the element
39
- String tagNameInp = driver .findElement (By .name ("email_input" )).getTagName ();
40
- assertEquals (tagNameInp ,"input" );
41
-
42
- // GetRect
43
- // Returns height, width, x and y coordinates referenced element
44
- Rectangle res = driver .findElement (By .name ("range_input" )).getRect ();
45
- // Rectangle class provides getX,getY, getWidth, getHeight methods
46
- assertEquals (res .getX (),10 );
47
-
48
-
49
- // Retrieves the computed style property 'font-size' of field
50
- String cssValue = driver .findElement (By .name ("color_input" )).getCssValue ("font-size" );
51
- assertEquals (cssValue , "13.3333px" );
52
-
53
-
54
- // GetText
55
- // Retrieves the text of the element
56
- String text = driver .findElement (By .tagName ("h1" )).getText ();
57
- assertEquals (text , "Testing Inputs" );
58
-
59
-
19
+ driver .manage ().timeouts ().implicitlyWait (Duration .ofMillis (500 ));
20
+ // Navigate to Url
21
+ driver .get ("https://www.selenium.dev/selenium/web/inputs.html" );
22
+
23
+ // isDisplayed
24
+ // Get boolean value for is element display
25
+ boolean isEmailVisible = driver .findElement (By .name ("email_input" )).isDisplayed ();
26
+ assertTrue (isEmailVisible );
27
+
28
+ // isEnabled
29
+ // returns true if element is enabled else returns false
30
+ boolean isEnabledButton = driver .findElement (By .name ("button_input" )).isEnabled ();
31
+ assertTrue (isEnabledButton );
32
+
33
+ // isSelected
34
+ // returns true if element is checked else returns false
35
+ boolean isSelectedCheck = driver .findElement (By .name ("checkbox_input" )).isSelected ();
36
+ assertTrue (isSelectedCheck );
37
+
38
+ // TagName
39
+ // returns TagName of the element
40
+ String tagNameInp = driver .findElement (By .name ("email_input" )).getTagName ();
41
+ assertEquals ("input" , tagNameInp );
42
+
43
+ // GetRect
44
+ // Returns height, width, x and y coordinates referenced element
45
+ Rectangle res = driver .findElement (By .name ("range_input" )).getRect ();
46
+ // Rectangle class provides getX,getY, getWidth, getHeight methods
47
+ assertEquals (10 , res .getX ());
48
+
49
+ // Retrieves the computed style property 'font-size' of field
50
+ String cssValue = driver .findElement (By .name ("color_input" )).getCssValue ("font-size" );
51
+ assertEquals (cssValue , "13.3333px" );
52
+
53
+
54
+ // GetText
55
+ // Retrieves the text of the element
56
+ String text = driver .findElement (By .tagName ("h1" )).getText ();
57
+ assertEquals (text , "Testing Inputs" );
58
+
59
+
60
60
// FetchAttributes
61
61
// identify the email text box
62
62
WebElement emailTxt = driver .findElement (By .name (("email_input" )));
63
63
// fetch the value property associated with the textbox
64
64
String valueInfo = emailTxt .getAttribute ("value" );
65
65
assertEquals (valueInfo ,"admin@localhost" );
66
-
67
-
68
- driver .quit ();
66
+
67
+
68
+ driver .quit ();
69
69
}
70
70
71
- }
71
+ }
0 commit comments