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