Advertisement
Guest User

Untitled

a guest
Feb 25th, 2020
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. //метод ожидания
  2.  
  3. protected void waitForVisibilityOf(By locator, Integer... timeOutInSeconds){
  4. int attempts =0;
  5. while (attempts <2){
  6. try {
  7. waitFor(ExpectedConditions.visibilityOfElementLocated(locator), (timeOutInSeconds.length >0 ? timeOutInSeconds[0]: null));
  8. break;
  9. } catch (StaleElementReferenceException e) {
  10.  
  11. }
  12. attempts ++;
  13. }
  14. }
  15. private void waitFor(ExpectedCondition<WebElement> condition, Integer timeOutInSeconds){
  16. timeOutInSeconds = timeOutInSeconds != null ? timeOutInSeconds :30;
  17. WebDriverWait wait = new WebDriverWait(driver, timeOutInSeconds);
  18. wait.until(condition);
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement