Testing Intellij 13 ultimate平稳运行geb测试,但独立运行时会等待

Testing Intellij 13 ultimate平稳运行geb测试,但独立运行时会等待,testing,selenium,groovy,cucumber,geb,Testing,Selenium,Groovy,Cucumber,Geb,我正在使用黄瓜groovy和geb。 这是我的个人资料和驱动程序 FirefoxProfile firefoxProfile = new FirefoxProfile(); firefoxProfile.setAcceptUntrustedCertificates(true); firefoxProfile.setAssumeUntrustedCertificateIssuer(false); firefoxProfile.setPreference("browser.helperApps.ne

我正在使用黄瓜groovy和geb。 这是我的个人资料和驱动程序

FirefoxProfile firefoxProfile = new FirefoxProfile();
firefoxProfile.setAcceptUntrustedCertificates(true);
firefoxProfile.setAssumeUntrustedCertificateIssuer(false);
firefoxProfile.setPreference("browser.helperApps.neverAsk.saveToDisk",
        "text/csv,application/pdf,application/csv,application/vnd.ms-excel");
firefoxProfile.setPreference("browser.download.manager.showAlertOnComplete",false);
firefoxProfile.setPreference("browser.download.manager.showWhenStarting", false);
firefoxProfile.setPreference("browser.download.manager.useWindow", false);
firefoxProfile.setPreference("browser.helperApps.deleteTempFileOnExit", true);
firefoxProfile.setPreference("webdriver.load.strategy", "unstable")

driver = {
    def driver = new FirefoxDriver(firefoxProfile)
    driver
}
这是我的步骤定义供参考,这是第一步

MyPage.setUrl(Globals.get(key))
to MyPage
waitFor(10,0) {
    ExpectedConditions.presenceOfElementLocated(By.tagName("title"))
}
at MyPage
我注意到,如果我在intellij中的MyPage上放置一个断点并进行调试,那么它会在该点中断,然后我可以继续。但是,如果我只是从Intellij或使用./gradlew clean cumber运行 然后页面加载并等待很长时间。我不认为它会继续只等一分钟检查

这里有什么问题

更新1


试着用一种更简单的方式来做:

在MyPage的子类中显式设置url-您应该尝试在每个页面中使用一个页面对象

定义一个at条件并使用它来测试waitFor条件,以便页面等待加载

默认情况下,at条件将等待其条件为真

不要使用ExpectedConditions,请尝试更通用的方法,如:

waitFor { title != "" }
在您的情况下,您没有正确指定真相陈述。虽然我不确定Globals.getmodule1.attrib.value返回什么?但是看起来你应该删除这一行,在其他地方做这个逻辑

调用值返回一个字符串

单元1

class MyPage extends Page{

    static url = ""

    static at = { 
        waitFor { module1.attrib.value() != ""  }
    }   
}

MyPage.setUrl(Globals.get(key))
to MyPage
at MyPage
只是吹毛求疵:

driver = {
    new FirefoxDriver(firefoxProfile)
}

Selenium和firefox的更新版本修复了该问题。
关闭此

您能从MyPage发布代码吗?我不想这样设置url,因为我正在为许多页面重复使用MyPage,所以我认为这是非常好的条件。我这样做的原因是firefox配置文件有一个首选项webdriver.load.strategy,它被设置为不稳定。这会导致selenium不等待页面完全加载。然后,下面的waitFor变得很重要,因为它是检查要加载的页面的良好条件。waitFor10,0{ExpectedConditions.presenceOfElementLocatedBy.tagnametTitle}我做的另一个观察是因为断点位于“atmypage”行,使用intellij调试me并没有给selenium更多的加载时间,而我直接使用上面提到的gradle命令运行,您可以通过更简单的方式使用Geb而不直接使用selenium来获得相同的结果。这就是重点。waitFor{$'body'.displayed}ok即使这样,页面仍会加载并等待很长时间
driver = {
    new FirefoxDriver(firefoxProfile)
}