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
import org.openqa.selenium.By; | |
import org.openqa.selenium.WebDriver; | |
import org.openqa.selenium.support.ui.ExpectedConditions; | |
import org.openqa.selenium.support.ui.WebDriverWait; | |
public class BadExample { | |
private WebDriver driver; | |
public BadExample(WebDriver driver) { | |
this.driver = driver; | |
} | |
public String clickElementAndGetText(String elementToClickId, String elementToReadId) { | |
// Click the element we want to click | |
driver.findElement(By.id(elementToClickId)).click(); | |
// Wait until the element we want to get the text from is visible | |
WebDriverWait wait = new WebDriverWait(driver, 10); | |
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id(elementToReadId))); | |
// Get the text from our read element and return it | |
return driver.findElement(By.id(elementToReadId)).getText(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment