本文整理匯總了Golang中github.com/sclevine/agouti.Page.SwitchToRootFrame方法的典型用法代碼示例。如果您正苦於以下問題:Golang Page.SwitchToRootFrame方法的具體用法?Golang Page.SwitchToRootFrame怎麽用?Golang Page.SwitchToRootFrame使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/sclevine/agouti.Page
的用法示例。
在下文中一共展示了Page.SwitchToRootFrame方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: itShouldBehaveLikeAPage
//.........這裏部分代碼省略.........
checkbox := page.Find("#some_checkbox")
Expect(checkbox.Check()).To(Succeed())
Expect(page.Refresh()).To(Succeed())
Expect(checkbox).NotTo(BeSelected())
})
})
// NOTE: browsers besides PhantomJS do not support JavaScript logs
if name == "PhantomJS" {
It("should support retrieving logs", func() {
Eventually(page).Should(HaveLoggedInfo("some log"))
Expect(page).NotTo(HaveLoggedError())
Eventually(page, "4s").Should(HaveLoggedError("ReferenceError: Can't find variable: doesNotExist\n (anonymous function)"))
})
}
It("should support switching frames", func() {
By("switching to an iframe", func() {
Expect(page.Find("#frame").SwitchToFrame()).To(Succeed())
Expect(page.Find("body")).To(MatchText("Example Domain"))
})
// NOTE: PhantomJS does not support Page.SwitchToParentFrame
if name != "PhantomJS" {
By("switching back to the default frame by referring to the parent frame", func() {
Expect(page.SwitchToParentFrame()).To(Succeed())
Expect(page.Find("body")).NotTo(MatchText("Example Domain"))
})
Expect(page.Find("#frame").SwitchToFrame()).To(Succeed())
}
By("switching back to the default frame by referring to the root frame", func() {
Expect(page.SwitchToRootFrame()).To(Succeed())
Expect(page.Find("body")).NotTo(MatchText("Example Domain"))
})
})
It("should support switching windows", func() {
Expect(page.Find("#new_window").Click()).To(Succeed())
Expect(page).To(HaveWindowCount(2))
By("switching windows", func() {
Expect(page.SwitchToWindow("new window")).To(Succeed())
Expect(page.Find("header")).NotTo(BeFound())
Expect(page.NextWindow()).To(Succeed())
Expect(page.Find("header")).To(BeFound())
})
By("closing windows", func() {
Expect(page.CloseWindow()).To(Succeed())
Expect(page).To(HaveWindowCount(1))
})
})
// NOTE: PhantomJS does not support popup boxes
if name != "PhantomJS" {
It("should support popup boxes", func() {
By("interacting with alert popups", func() {
Expect(page.Find("#popup_alert").Click()).To(Succeed())
Expect(page).To(HavePopupText("some alert"))
Expect(page.ConfirmPopup()).To(Succeed())
})
By("interacting with confirm boxes", func() {
var confirmed bool
示例2: testPage
//.........這裏部分代碼省略.........
checkbox := page.Find("#some_checkbox")
Expect(checkbox.Check()).To(Succeed())
Expect(page.Refresh()).To(Succeed())
Expect(checkbox).NotTo(BeSelected())
})
})
// NOTE: browsers besides PhantomJS do not support JavaScript logs
if browserName == "PhantomJS" {
It("should support retrieving logs", func() {
Eventually(page).Should(HaveLoggedInfo("some log"))
Expect(page).NotTo(HaveLoggedError())
Eventually(page, "4s").Should(HaveLoggedError("ReferenceError: Can't find variable: doesNotExist\n (anonymous function)"))
})
}
It("should support switching frames", func() {
By("switching to an iframe", func() {
Expect(page.Find("#frame").SwitchToFrame()).To(Succeed())
Expect(page.Find("body")).To(MatchText("Example Domain"))
})
// NOTE: PhantomJS does not support Page.SwitchToParentFrame
if browserName != "PhantomJS" {
By("switching back to the default frame by referring to the parent frame", func() {
Expect(page.SwitchToParentFrame()).To(Succeed())
Expect(page.Find("body")).NotTo(MatchText("Example Domain"))
})
Expect(page.Find("#frame").SwitchToFrame()).To(Succeed())
}
By("switching back to the default frame by referring to the root frame", func() {
Expect(page.SwitchToRootFrame()).To(Succeed())
Expect(page.Find("body")).NotTo(MatchText("Example Domain"))
})
})
It("should support switching windows", func() {
Expect(page.Find("#new_window").Click()).To(Succeed())
Expect(page).To(HaveWindowCount(2))
By("switching windows", func() {
Expect(page.SwitchToWindow("new window")).To(Succeed())
Expect(page.Find("header")).NotTo(BeFound())
Expect(page.NextWindow()).To(Succeed())
Expect(page.Find("header")).To(BeFound())
})
By("closing windows", func() {
Expect(page.CloseWindow()).To(Succeed())
Expect(page).To(HaveWindowCount(1))
})
})
// NOTE: PhantomJS does not support popup boxes
if browserName != "PhantomJS" {
It("should support popup boxes", func() {
By("interacting with alert popups", func() {
Expect(page.Find("#popup_alert").Click()).To(Succeed())
Expect(page).To(HavePopupText("some alert"))
Expect(page.ConfirmPopup()).To(Succeed())
})
By("interacting with confirm boxes", func() {
var confirmed bool