【发布时间】:2017-01-16 10:55:23
【问题描述】:
为什么我的显式等待不起作用?
我的隐式等待有效,但我的显式等待似乎没有使用分配的超时时间?
例如,如果我将显式超时设置为 300 秒,它将恢复为隐式超时,或者如果我注释掉隐式超时,它将立即引发错误/超时异常。
使用的代码:
public class Base_Page extends TestListenerAdapter {
public @FindBy(css = ".ajax_loader") WebElement ajaxLoadScreen;
public @FindBy(css = "#preloaderSpinner") WebElement preloadSpinner;
public WebDriver driver;
public String packageName;
public String className;
public WebDriverWait wait;
protected JavascriptExecutor jsExecutor;
public Base_Page(WebDriver driver) throws Exception {
this.driver = driver;
this.wait = new WebDriverWait(this.driver, 300);
this.driver.manage().window().maximize();
this.driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
this.driver.manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS);
Properties p = new Properties();
FileInputStream fi = new FileInputStream(Constant.CONFIG_PROPERTIES_DIRECTORY);
p.load(fi);
this.browser_type = p.getProperty("browser");
this.page_url = p.getProperty("url");
}
public void loadPage() throws Exception {
this.driver.get(page_url);
}
public void clickMyAccount() {
driver.findElement(By.xpath(".//*[@id='account_links']/li[1]/a2")).click();
}
public void clickHelp() {
this.driver.findElement(By.xpath(".//*[@id='help_links']/li[1]/a")).click();
}
【问题讨论】:
-
将您的代码显示为文本而不是图像
-
@Andersson 全部完成
-
你在哪里使用显式等待?
-
嗨@Josh,我附上了一张图片,显示了我在哪里使用了显式等待
-
你在哪里使用 clickMyAccount() ?
标签: selenium selenium-webdriver webdriver