화면이 로딩되기 전에 요소를 선택하면 NoSuchElementException 오류가 발생한다.
이런 상황을 방지하기 위해서 Wait을 사용한다.
wait에는 두 가지가 있다.
]- 암시적 대기 (implicitly Wait)
- 스크립트의 모든 요소에 적용된다
- 요소가 암시적 대기열에 지정도니 시간 프레임에 있을 때 사용하는 것이 좋다.
- 명시적 대기 (Explicitly Wait)
- 우리가 의도한 요소에서만 적용된다.
- 요소를 로드하는데 시가닝 오래 걸리지만 요소의 속성을 확인하는데 사용할 때 좋다
WebDriverWait wait = new WebDriverWait(driver,10);
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
WebDriverWait wait = new WebDriverWait(driver,10);
wait.until(ExpectedConditions.alertIsPresent());
driver.switchTo().alert().accept();
wait.until(ExpectedConditions.titleContains("게시판"));
wait.until(ExpectedConditions.elementToBeClickable(By.id("board_name")));
'IT > UITEST' 카테고리의 다른 글
Selenium을 이용한 UI TEST (0) | 2019.05.07 |
---|---|
UI-Test-09 select를 선택하는 3가지 방법 (0) | 2019.05.07 |
UITest08 - UITEST07을 이용한 검사 (0) | 2019.05.06 |
UITest07 유효성 테스트 (0) | 2019.05.06 |
UI-Test-06 자바스크립트 함수 실행 방법 (0) | 2019.05.06 |