Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interaction code branch #1459

Merged
merged 14 commits into from
Aug 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package dev.selenium.elements.interactions;

import org.junit.jupiter.api.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import java.time.Duration;
import static org.junit.jupiter.api.Assertions.assertEquals;

public class ElementInteraction {

@Test
public void interactWithElements() {
WebDriver driver = new ChromeDriver();
driver.manage().timeouts().implicitlyWait(Duration.ofMillis(500));
// 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"));
checkInput.click();
Boolean isChecked=checkInput.isSelected();
assertEquals(isChecked,false);

//SendKeys
// Clear field to empty it from any previous data
WebElement emailInput=driver.findElement(By.name("email_input"));
emailInput.clear();
//Enter Text
String email="[email protected]";
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, "");

driver.quit();
}

}