Keyboards Test
This commit is contained in:
@@ -2,6 +2,7 @@ package com.agile611.testng.webdriver;
|
|||||||
|
|
||||||
import org.openqa.selenium.By;
|
import org.openqa.selenium.By;
|
||||||
import org.openqa.selenium.Keys;
|
import org.openqa.selenium.Keys;
|
||||||
|
import org.openqa.selenium.WebElement;
|
||||||
import org.openqa.selenium.interactions.Actions;
|
import org.openqa.selenium.interactions.Actions;
|
||||||
import static org.testng.Assert.assertTrue;
|
import static org.testng.Assert.assertTrue;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
@@ -12,10 +13,14 @@ public class KeyboardKeysTest extends BaseTest {
|
|||||||
driver.get("http://the-internet.herokuapp.com/key_presses");
|
driver.get("http://the-internet.herokuapp.com/key_presses");
|
||||||
Actions builder = new Actions(driver);
|
Actions builder = new Actions(driver);
|
||||||
builder.sendKeys(Keys.SPACE).build().perform();
|
builder.sendKeys(Keys.SPACE).build().perform();
|
||||||
Thread.sleep(2000);
|
|
||||||
assertTrue(driver.findElement(By.id("result")).getText().equalsIgnoreCase("You entered: SPACE"));
|
assertTrue(driver.findElement(By.id("result")).getText().equalsIgnoreCase("You entered: SPACE"));
|
||||||
builder.sendKeys(Keys.LEFT).build().perform();
|
builder.sendKeys(Keys.LEFT).build().perform();
|
||||||
Thread.sleep(2000);
|
|
||||||
assertTrue(driver.findElement(By.id("result")).getText().equalsIgnoreCase("You entered: LEFT"));
|
assertTrue(driver.findElement(By.id("result")).getText().equalsIgnoreCase("You entered: LEFT"));
|
||||||
|
|
||||||
|
WebElement textBox = driver.findElement(By.id("target"));
|
||||||
|
textBox.click();
|
||||||
|
textBox.sendKeys("Hello World");
|
||||||
|
textBox.sendKeys(Keys.ESCAPE);
|
||||||
|
assertTrue(driver.findElement(By.id("result")).getText().equalsIgnoreCase("You entered: ESCAPE"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user