page页面嵌入iframe 如何调用方法
class CustomerInformationPage extends Page {
static at = {$('span.tabs-title',2).text() == '客户信息'}
static content = {
loginFrame(page: CustomerInformationPageIFrame) {
$(By.xpath('//*[@url="/ifincars/sales/apply/jsp/ApplyCustomInfo.jsp"]'))
}
}
//调用CustomerInformationPageIFrame页面封装的方法,填写客户全部信息
def AddTenantInformation(TenantInformation tenantInformation){
withFrame(loginFrame) {
//填写基本信息
addTenantInformation(tenantInformation)
//增加驾驶人
newDrivers("测试驾驶人","110101199003070628")
//增加联系人1
newContacts("测试一号","15704789740")
//增加联系人2号
newContacts("测试二号","15703124561")
//点击保存
save()
}
}
}
withFrame() 方法有多种变种,但是所有这些 withFrame 方法的最后一个闭包参数都是在它的第一个参数指定的 frame 的上下文中执行的。闭包参数执行后的返回值就作为 withFrame() 方法的返回值,并且执行完成后,浏览器的当前页面会被恢复成执行 withFrame 方法之前的页面。下面是各种形式的 withFrame 方法:
withFrame(String, Closure) - String 参数是 frame 元素的 name 或 id
withFrame(int, Closure) - int 参数表示 frame 元素的索引,例如,页面中包含 3 个 frame 元素,那么第一个 frame 的下标 为 0,第二个为 1,依此类推
withFrame(Navigator, Closure) - Navigator 参数应该包含一个 frame 元素
withFrame(SimplePageContent, Closure) - SimplePageContent 是页面内容模版返回的一个类型,它应该包含一个 frame 元素