Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d973e62
commit 6be7a85
Showing
3 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
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
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,28 @@ | ||
package pages; | ||
|
||
import org.openqa.selenium.By; | ||
import org.openqa.selenium.Keys; | ||
import org.openqa.selenium.WebDriver; | ||
|
||
public class KeyPressesPage { | ||
|
||
private WebDriver driver; | ||
private By inputField = By.id("target"); | ||
private By resultText = By.id("result"); | ||
|
||
public KeyPressesPage(WebDriver driver){ | ||
this.driver = driver; | ||
} | ||
|
||
public void enterText(String text){ | ||
driver.findElement(inputField).sendKeys(text); | ||
} | ||
|
||
public void enterPi(){ | ||
enterText(Keys.chord(Keys.ALT, "p") + "=3.14"); | ||
} | ||
|
||
public String getResult(){ | ||
return driver.findElement(resultText).getText(); | ||
} | ||
} |
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,27 @@ | ||
package keys; | ||
|
||
import base.BaseTests; | ||
import org.openqa.selenium.Keys; | ||
import org.testng.annotations.Test; | ||
|
||
import static org.testng.Assert.assertEquals; | ||
|
||
public class KeysTests extends BaseTests { | ||
|
||
@Test | ||
public void testBackspace(){ | ||
var keyPage = homePage.clickKeyPresses(); | ||
keyPage.enterText("A" + Keys.BACK_SPACE); | ||
assertEquals(keyPage.getResult(), "You entered: BACK_SPACE"); | ||
} | ||
|
||
@Test | ||
public void testPi(){ | ||
var keyPage = homePage.clickKeyPresses(); | ||
keyPage.enterPi(); | ||
/* | ||
NOTE: we didn't finish this test in the video. | ||
We debugged to watch it enter the pi key | ||
*/ | ||
} | ||
} |