Skip to content

Instantly share code, notes, and snippets.

@qagoose

qagoose/Example.java Secret

Created Apr 15, 2018
Embed
What would you like to do?
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 Example {
private WebDriver driver;
public Example(WebDriver driver) {
this.driver = driver;
}
public String clickElementAndGetText(By elementToClick, By elementToRead) {
// Click the element we want to click
driver.findElement(elementToClick).click();
// Wait until the element we want to get the text from is visible
WebDriverWait wait = new WebDriverWait(driver, 10);
wait.until(ExpectedConditions.visibilityOfElementLocated(elementToRead));
// Get the text from our read element and return it
return driver.findElement(elementToRead).getText();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.