Skip to content

Commit

Permalink
Fix typos in two files
Browse files Browse the repository at this point in the history
In two files fixed typos and refactor the files.

Fixes SeleniumHQ#1
  • Loading branch information
Tuscann committed Aug 24, 2024
1 parent 0fde8cc commit 85cdbf6
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 70 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,61 +11,56 @@

public class InformationTest {

@Test
public void informationWithElements() {

WebDriver driver = new ChromeDriver();
driver.manage().timeouts().implicitlyWait(Duration.ofMillis(500));
// Navigate to Url
driver.get("https://www.selenium.dev/selenium/web/inputs.html");
@Test
public void informationWithElements() {

// isDisplayed
// Get boolean value for is element display
boolean isEmailVisible = driver.findElement(By.name("email_input")).isDisplayed();
assertEquals(isEmailVisible,true);
WebDriver driver = new ChromeDriver();
driver.manage().timeouts().implicitlyWait(Duration.ofMillis(500));
// Navigate to Url
driver.get("https://www.selenium.dev/selenium/web/inputs.html");

//isEnabled
//returns true if element is enabled else returns false
boolean isEnabledButton = driver.findElement(By.name("button_input")).isEnabled();
assertEquals(isEnabledButton,true);
// isDisplayed
// Get boolean value for is element display
boolean isEmailVisible = driver.findElement(By.name("email_input")).isDisplayed();
assertEquals(isEmailVisible, true);

//isSelected
//returns true if element is checked else returns false
boolean isSelectedCheck = driver.findElement(By.name("checkbox_input")).isSelected();
assertEquals(isSelectedCheck,true);
// isEnabled
// Returns true if element is enabled else returns false
boolean isEnabledButton = driver.findElement(By.name("button_input")).isEnabled();
assertEquals(isEnabledButton, true);

//TagName
//returns TagName of the element
String tagNameInp = driver.findElement(By.name("email_input")).getTagName();
assertEquals(tagNameInp,"input");
// isSelected
// Returns true if element is checked else returns false
boolean isSelectedCheck = driver.findElement(By.name("checkbox_input")).isSelected();
assertEquals(isSelectedCheck, true);

//GetRect
// Returns height, width, x and y coordinates referenced element
Rectangle res = driver.findElement(By.name("range_input")).getRect();
// Rectangle class provides getX,getY, getWidth, getHeight methods
assertEquals(res.getX(),10);


// Retrieves the computed style property 'font-size' of field
String cssValue = driver.findElement(By.name("color_input")).getCssValue("font-size");
assertEquals(cssValue, "13.3333px");


//GetText
// Retrieves the text of the element
String text = driver.findElement(By.tagName("h1")).getText();
assertEquals(text, "Testing Inputs");


//FetchAttributes
//identify the email text box
WebElement emailTxt = driver.findElement(By.name(("email_input")));
//fetch the value property associated with the textbox
String valueInfo = emailTxt.getAttribute("value");
assertEquals(valueInfo,"admin@localhost");


driver.quit();
}
// TagName
// Returns TagName of the element
String tagNameInp = driver.findElement(By.name("email_input")).getTagName();
assertEquals(tagNameInp, "input");

// GetRect
// Returns height, width, x and y coordinates referenced element
Rectangle res = driver.findElement(By.name("range_input")).getRect();
// Rectangle class provides getX,getY, getWidth, getHeight methods
assertEquals(res.getX(), 10);

// Retrieves the computed style property 'font-size' of field
String cssValue = driver.findElement(By.name("color_input")).getCssValue("font-size");
assertEquals(cssValue, "13.3333px");

// GetText
// Retrieves the text of the element
String text = driver.findElement(By.tagName("h1")).getText();
assertEquals(text, "Testing Inputs");

// FetchAttributes
// Identify the email text box
WebElement emailTxt = driver.findElement(By.name(("email_input")));
// fetch the value property associated with the textbox
String valueInfo = emailTxt.getAttribute("value");
assertEquals(valueInfo, "admin@localhost");

driver.quit();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import java.time.Duration;
import static org.junit.jupiter.api.Assertions.assertEquals;

public class InteractionTest{
public class InteractionTest {

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

// Click on the element
WebElement checkInput=driver.findElement(By.name("checkbox_input"));
// Click on the element
WebElement checkInput = driver.findElement(By.name("checkbox_input"));
checkInput.click();
Boolean isChecked=checkInput.isSelected();
assertEquals(isChecked,false);
Boolean isChecked = checkInput.isSelected();
assertEquals(isChecked, false);

//SendKeys
// SendKeys
// Clear field to empty it from any previous data
WebElement emailInput=driver.findElement(By.name("email_input"));
WebElement emailInput = driver.findElement(By.name("email_input"));
emailInput.clear();
//Enter Text
String email="admin@localhost.dev";
emailInput.sendKeys(email);
//Verify
String data=emailInput.getAttribute("value");
assertEquals(data,email);


//Clear Element
// Enter Text
String email = "admin@localhost.dev";
emailInput.sendKeys(email);
// Verify
String data = emailInput.getAttribute("value");
assertEquals(data, email);

// Clear Element
// Clear field to empty it from any previous data
emailInput.clear();
data=emailInput.getAttribute("value");
assertEquals(data, "");
data = emailInput.getAttribute("value");
assertEquals(data, "");

driver.quit();
}

}

0 comments on commit 85cdbf6

Please sign in to comment.