在http://seleniumhq.org/docs/03_webdriver.jsp中,它显示了以下Java示例代码
(new WebDriverWait(driver, 10)).until(new ExpectedCondition<Boolean>() {
public Boolean apply(WebDriver d) {
return d.getTitle().toLowerCase().startsWith("cheese!");
}
});有没有可能用CFML写上面的代码,也许可以借助cf10的dynamic proxy
如果我们能让cf10的closure与上面的代码样本一起工作,那就太棒了,但由于预期的Java接口和Java返回类型,它似乎不能工作,我说的对吗?
发布于 2013-01-23 11:14:32
我不确定哪个是更好的选择。但是使用动态代理也是可能的。只需创建一个实现ExpectedCondition接口的cfc:
component {
public boolean function apply(Any d) {
return d.getTitle().toLowerCase().startsWith("cheese!");
}
}然后创建代理的一个实例,并将其传递给WebDriverWait的构造函数
<cfscript>
driver = createObject("java", "org.openqa.selenium.firefox.FirefoxDriver").init();
driver.get("http://www.google.com");
by = createObject("java", "org.openqa.selenium.By");
element = driver.findElement(By.name("q"));
WriteDump("Page title is: "& driver.getTitle());
element.sendKeys(["Cheese!"]);
element.submit();
conditionProxy = createDynamicProxy("test.ExpectedConditionProxy", ["org.openqa.selenium.support.ui.ExpectedCondition"]);
WebDriverWait = createObject("java", "org.openqa.selenium.support.ui.WebDriverWait");
WebDriverWait.init(driver, 10).until( conditionProxy );
WriteDump("Page title is: "& driver.getTitle());
driver.quit();
</cfscript>https://stackoverflow.com/questions/14471153
复制相似问题