如何在等待预期条件时单击功能?

时间:2014-04-24 18:02:22

标签: java selenium-webdriver

在等待预期的情况时,我们可以继续点击搜索按钮吗?

int time_out = 0;   
while (driver.findElement(By.xpath("//*[@id='searchResults']/p/span")).isDisplayed() &&time_out != 20 )
    {   
        if(!driver.findElement(By.xpath("//*[@id='searchResults']/div[1]/div[1]/*")).isDisplayed())
        {
            driver.findElement(By.xpath(".//*[@id='searchItem']")).click();
            Thread.sleep(3000);
            time_out++;
        }
        else
        {
            //click on the activation code
            driver.findElement(By.xpath((".//*[@id='searchResults']/div[1]/div[1]/*"))).click();
        }
    }

我尝试了这个,但不知何故不起作用。

0 个答案:

没有答案