Skip to content

Commit

Permalink
Interaction code branch (#1459)
Browse files Browse the repository at this point in the history
* added code for isdisplayed kotlin

* added elementinteraction.java file

---------

Co-authored-by: Diego Molina <[email protected]>
Co-authored-by: Sri Harsha <[email protected]>
  • Loading branch information
3 people authored Aug 23, 2023
1 parent 04def35 commit 9b52969
Showing 1 changed file with 47 additions and 0 deletions.
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();
}

}

0 comments on commit 9b52969

Please sign in to comment.