Skip to content

Commit 85cdbf6

Browse files
committed
Fix typos in two files
In two files fixed typos and refactor the files. Fixes #1
1 parent 0fde8cc commit 85cdbf6

File tree

2 files changed

+63
-70
lines changed

2 files changed

+63
-70
lines changed

examples/java/src/test/java/dev/selenium/elements/InformationTest.java

Lines changed: 46 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -11,61 +11,56 @@
1111

1212
public class InformationTest {
1313

14-
@Test
15-
public void informationWithElements() {
16-
17-
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");
14+
@Test
15+
public void informationWithElements() {
2116

22-
// isDisplayed
23-
// Get boolean value for is element display
24-
boolean isEmailVisible = driver.findElement(By.name("email_input")).isDisplayed();
25-
assertEquals(isEmailVisible,true);
17+
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");
2621

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);
22+
// isDisplayed
23+
// Get boolean value for is element display
24+
boolean isEmailVisible = driver.findElement(By.name("email_input")).isDisplayed();
25+
assertEquals(isEmailVisible, true);
3126

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);
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);
3631

37-
//TagName
38-
//returns TagName of the element
39-
String tagNameInp = driver.findElement(By.name("email_input")).getTagName();
40-
assertEquals(tagNameInp,"input");
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);
4136

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-
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");
66-
67-
68-
driver.quit();
69-
}
37+
// TagName
38+
// Returns TagName of the element
39+
String tagNameInp = driver.findElement(By.name("email_input")).getTagName();
40+
assertEquals(tagNameInp, "input");
7041

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+
// Retrieves the computed style property 'font-size' of field
49+
String cssValue = driver.findElement(By.name("color_input")).getCssValue("font-size");
50+
assertEquals(cssValue, "13.3333px");
51+
52+
// GetText
53+
// Retrieves the text of the element
54+
String text = driver.findElement(By.tagName("h1")).getText();
55+
assertEquals(text, "Testing Inputs");
56+
57+
// FetchAttributes
58+
// Identify the email text box
59+
WebElement emailTxt = driver.findElement(By.name(("email_input")));
60+
// fetch the value property associated with the textbox
61+
String valueInfo = emailTxt.getAttribute("value");
62+
assertEquals(valueInfo, "admin@localhost");
63+
64+
driver.quit();
65+
}
7166
}

examples/java/src/test/java/dev/selenium/elements/InteractionTest.java

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import java.time.Duration;
99
import static org.junit.jupiter.api.Assertions.assertEquals;
1010

11-
public class InteractionTest{
11+
public class InteractionTest {
1212

1313
@Test
1414
public void interactWithElements() {
@@ -17,31 +17,29 @@ public void interactWithElements() {
1717
// Navigate to Url
1818
driver.get("https://www.selenium.dev/selenium/web/inputs.html");
1919

20-
// Click on the element
21-
WebElement checkInput=driver.findElement(By.name("checkbox_input"));
20+
// Click on the element
21+
WebElement checkInput = driver.findElement(By.name("checkbox_input"));
2222
checkInput.click();
23-
Boolean isChecked=checkInput.isSelected();
24-
assertEquals(isChecked,false);
23+
Boolean isChecked = checkInput.isSelected();
24+
assertEquals(isChecked, false);
2525

26-
//SendKeys
26+
// SendKeys
2727
// Clear field to empty it from any previous data
28-
WebElement emailInput=driver.findElement(By.name("email_input"));
28+
WebElement emailInput = driver.findElement(By.name("email_input"));
2929
emailInput.clear();
30-
//Enter Text
31-
String email="admin@localhost.dev";
32-
emailInput.sendKeys(email);
33-
//Verify
34-
String data=emailInput.getAttribute("value");
35-
assertEquals(data,email);
36-
37-
38-
//Clear Element
30+
// Enter Text
31+
String email = "admin@localhost.dev";
32+
emailInput.sendKeys(email);
33+
// Verify
34+
String data = emailInput.getAttribute("value");
35+
assertEquals(data, email);
36+
37+
// Clear Element
3938
// Clear field to empty it from any previous data
4039
emailInput.clear();
41-
data=emailInput.getAttribute("value");
42-
assertEquals(data, "");
40+
data = emailInput.getAttribute("value");
41+
assertEquals(data, "");
4342

4443
driver.quit();
4544
}
46-
4745
}

0 commit comments

Comments
 (0)