Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public WebElement findElement(String path, Pather type, TimeOut timeOut) {
- try {
- WebDriverWait wait = new WebDriverWait(driver, timeOut.value);
- WebElement element = null;
- switch (type) {
- case className:
- element = wait.until(ExpectedConditions.presenceOfElementLocated(By.className(path)));
- break;
- case id:
- element = wait.until(ExpectedConditions.presenceOfElementLocated(By.id(path)));
- break;
- case name:
- element = wait.until(ExpectedConditions.presenceOfElementLocated(By.name(path)));
- break;
- case xPath:
- element = wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath(path)));
- break;
- case cssSelector:
- element = wait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector(path)));
- break;
- case linkText:
- element = wait.until(ExpectedConditions.presenceOfElementLocated(By.linkText(path)));
- break;
- default:
- new NotFoundException();
- }
- return element;
- }
- catch (Exception ex)
- {
- return null;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement