Working with Java Instrumentation
from root folder, execute following to test for Java Instrumentation
mvn clean install java -javaagent:./target/JavaInstrumentationExample-0.0.1-SNAPSHOT.jar com.oliver.javaagent.helloworldagent.Client
Output:
Hello World! Java Agent Hello World! Client
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10)); WebElement element = wait.until(ExpectedConditions.presenceOfElementLocated(By.id("example")));
example methods: visibilityOfNestedElementsLocatedBy visibilityOfElementLocated visibilityOfAllElementsLocatedBy visibilityOfAllElements visibilityOf(org.openqa.selenium.WebElement element)
urlToBe(java.lang.String url) urlMatches(java.lang.String regex)
titleIs(java.lang.String title)
textToBePresentInElementValue(org.openqa.selenium.WebElement element, java.lang.String text)
textToBe(org.openqa.selenium.By locator, java.lang.String value) stalenessOf(org.openqa.selenium.WebElement element)
refreshed(ExpectedCondition condition)
presenceOfNestedElementsLocatedBy
numberOfWindowsToBe(int expectedNumberOfWindows)
numberOfElementsToBeLessThan(org.openqa.selenium.By locator, java.lang.Integer number)
jsReturnsValue(java.lang.String javaScript)
javaScriptThrowsNoExceptions(java.lang.String javaScript)
invisibilityOfElementWithText(org.openqa.selenium.By locator, java.lang.String text)
frameToBeAvailableAndSwitchToIt(java.lang.String frameLocator)
elementToBeSelected(org.openqa.selenium.WebElement element)
elementToBeClickable(org.openqa.selenium.WebElement element)
elementSelectionStateToBe(org.openqa.selenium.WebElement element, boolean selected)
attributeToBeNotEmpty(org.openqa.selenium.WebElement element, java.lang.String attribute)
attributeToBe(org.openqa.selenium.WebElement element, java.lang.String attribute, java.lang.String value)
attributeContains(org.openqa.selenium.By locator, java.lang.String attribute, java.lang.String value)
import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait;
import java.time.Duration;
public class ExpectedConditionORExample { public static void main(String[] args) { WebDriver driver = new ChromeDriver(); driver.get("https://www.example.com");
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));
WebElement element = wait.until(
ExpectedConditions.or(
ExpectedConditions.visibilityOfElementLocated(By.id("firstElement")),
ExpectedConditions.visibilityOfElementLocated(By.id("secondElement"))
)
);
driver.quit();
}
}
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));
wait.until( ExpectedConditions.and( ExpectedConditions.visibilityOfElementLocated(By.id("firstElement")), ExpectedConditions.visibilityOfElementLocated(By.id("secondElement")) ) );
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));
wait.until( ExpectedConditions.not( ExpectedConditions.visibilityOfElementLocated(By.id("hiddenElement")) ) );