-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 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
1 parent
04def35
commit 9b52969
Showing
1 changed file
with
47 additions
and
0 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
examples/java/src/test/java/dev/selenium/elements/interactions/ElementInteraction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
|
||
} |