This file contains hidden or 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
| #content { | |
| margin: 20px; | |
| } | |
| .block { | |
| margin-top: 10px; | |
| } | |
| .block .btn { | |
| cursor: pointer; | |
| float: left; | |
| margin: 0 10px 10px; |
This file contains hidden or 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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> | |
| <script src="http://cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.0.0-rc.3/handlebars.js"></script> | |
| <script src="http://cdnjs.cloudflare.com/ajax/libs/ember.js/1.0.0-rc.6/ember.min.js"></script> | |
| <meta charset=utf-8 /> | |
| <title>JS Bin</title> | |
| </head> | |
| <body> |
This file contains hidden or 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
| driver.findElement(withTagName("input") | |
| .toRightOf(By.tagName("button"))) | |
| .sendKeys("hello"); |
This file contains hidden or 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
| public boolean isWebElementPresent() { | |
| return driver.findElements(By.testLocator).size() > 0 | |
| } |
This file contains hidden or 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
| public class NullWebElement implements WebElement { | |
| private NullWebElement() {} | |
| private static NullWebElement instance; | |
| public static NullWebElement getNull() { | |
| if (instance == null) { | |
| instance = new NullWebElement(); | |
| } |
This file contains hidden or 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
| public WebElement findElement(By by) { | |
| try { | |
| WebDriverWait wait = new WebDriverWait(driver, 5); | |
| return wait.until(ExpectedConditions.visibilityOfElementLocated(by)); | |
| } catch (Exception e) { | |
| return NullWebElement.getNull(); | |
| } | |
| } | |
| public List<WebElement> findElements(By by) { |
This file contains hidden or 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
| public static void click(WebElement webElement) { | |
| WebDriverWait wait = new WebDriverWait(driver(), 30); | |
| ExpectedCondition<Boolean> elementIsClickable = arg0 -> { | |
| try { | |
| webElement.click(); | |
| return true; | |
| } catch (Exception e) { | |
| return false; | |
| } | |
| }; |
This file contains hidden or 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
| public static void click(WebElement webElement) { | |
| String source = driver.getPageSource(); | |
| WebDriverWait wait = new WebDriverWait(driver(), 30); | |
| ExpectedCondition<Boolean> elementIsClickable = arg0 -> { | |
| try { | |
| webElement.click(); | |
| return !driver.getPageSource().equals(source); | |
| } catch (Exception e) { |
This file contains hidden or 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
| public static void type(String text, WebElement webElement) { | |
| if (text == null) { | |
| return; | |
| } | |
| new WebDriverWait(driver(), 30).until((WebDriver) -> { | |
| try { | |
| webElement.clear(); | |
| if (webElement.getAttribute("value").length() > 0) { |
This file contains hidden or 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
| public class LoginPage { | |
| private final WebDriver webDriver; | |
| @FindBy(linkText = "Log in") | |
| private WebElement login; | |
| @FindBy(id = "username") | |
| private WebElement usernameInput; | |
| @FindBy(id = "password") |
OlderNewer