2017-02-22 5 views
-1

이 작업을 수행해야합니다. 1. 2. Explicit Wait을 30 초 동안 사용하십시오. 3. 시작 버튼을 클릭하고 Hello World!를 확인하십시오.명시 적 대기 및 확인 Hello world

다음 코드를 작성했지만 element.getText는 null입니다.

driver.get("http://the-internet.herokuapp.com/dynamic_loading/1"); 
    WebDriverWait wait=new WebDriverWait(driver, 30); 
    WebElement all=driver.findElement(By.xpath("//*[@id='start']/button")); 
    all.click(); 
    WebElement element=wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//*[@id='finish']/h4"))); 
    driver.findElement(By.xpath("//*[@id='finish']/h4")); 
    String text=element.getText(); 
    System.out.println("hi:"+text); 
    //assertEquals("Hello World!", text); 

답변

1

변경 ExpectedConditions.presenceOfElementLocated

ExpectedConditions.visibilityOfElementLocated

당신이 presenceOfElementLocated를 사용하려면, 그것은 지정된 요소가 발견되면 상관없이 가시성이되어 무엇을, 볼에 DOM을 확인합니다. 따라서 요소는 DOM에 있지만 아직 보이지 않으므로 텍스트는 null로 나타납니다.

한편, visibilityOfElementLocated은 지정된 요소가 사용 가능하고 표시되는지 확인합니다.