Skip to content

Commit 9b52969

Browse files
pallavigitworkdiemolharsha509
authored
Interaction code branch (#1459)
* added code for isdisplayed kotlin * added elementinteraction.java file --------- Co-authored-by: Diego Molina <diemol@users.noreply.github.com> Co-authored-by: Sri Harsha <12621691+harsha509@users.noreply.github.com>
1 parent 04def35 commit 9b52969

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package dev.selenium.elements.interactions;
2+
3+
import org.junit.jupiter.api.Test;
4+
import org.openqa.selenium.By;
5+
import org.openqa.selenium.WebDriver;
6+
import org.openqa.selenium.WebElement;
7+
import org.openqa.selenium.chrome.ChromeDriver;
8+
import java.time.Duration;
9+
import static org.junit.jupiter.api.Assertions.assertEquals;
10+
11+
public class ElementInteraction {
12+
13+
@Test
14+
public void interactWithElements() {
15+
WebDriver driver = new ChromeDriver();
16+
driver.manage().timeouts().implicitlyWait(Duration.ofMillis(500));
17+
// Navigate to Url
18+
driver.get("https://www.selenium.dev/selenium/web/inputs.html");
19+
20+
// Click on the element
21+
WebElement checkInput=driver.findElement(By.name("checkbox_input"));
22+
checkInput.click();
23+
Boolean isChecked=checkInput.isSelected();
24+
assertEquals(isChecked,false);
25+
26+
//SendKeys
27+
// Clear field to empty it from any previous data
28+
WebElement emailInput=driver.findElement(By.name("email_input"));
29+
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
39+
// Clear field to empty it from any previous data
40+
emailInput.clear();
41+
data=emailInput.getAttribute("value");
42+
assertEquals(data, "");
43+
44+
driver.quit();
45+
}
46+
47+
}

0 commit comments

Comments
 (0)