本文整理汇总了Golang中github.com/sclevine/agouti.Page.ConfirmPopup方法的典型用法代码示例。如果您正苦于以下问题:Golang Page.ConfirmPopup方法的具体用法?Golang Page.ConfirmPopup怎么用?Golang Page.ConfirmPopup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/sclevine/agouti.Page
的用法示例。
在下文中一共展示了Page.ConfirmPopup方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1:
By("login", func() {
Eventually(page.Find("#login"), "10s").Should(BeFound())
Eventually(page.Find("#login"), "10s").Should(HaveText("Login"))
// Give some time to follow the demo
time.Sleep(2 * time.Second)
Expect(page.Find("#login").FindByLink("Login").Click()).To(Succeed())
Expect(page.Find("#username-modal").Fill("user")).To(Succeed())
Expect(page.Find("#password-modal").Fill("password")).To(Succeed())
Expect(page.Find("#password-modal").Fill("password")).To(Succeed())
time.Sleep(time.Second)
Expect(page.Find(".fa-sign-in").Click()).To(Succeed())
Eventually(page).Should(HavePopupText("Logged in as user"))
Expect(page.ConfirmPopup()).To(Succeed())
Eventually(page.Find("#howdy"), "10s").Should(HaveText("Logged in as User Name"))
})
By("go to catalogue", func() {
Expect(page.FindByLink("Catalogue").Click()).To(Succeed())
Eventually(page, "10s").Should(HaveURL("http://localhost:9102/category.html"))
})
By("add item in the cart", func() {
time.Sleep(4 * time.Second)
Expect(page.First(".product").Find(".fa-shopping-cart").Click()).To(Succeed())
Eventually(page.Find("#numItemsInCart"), "10s").Should(HaveText("1 item(s) in cart"))
})
示例2: itShouldBehaveLikeAPage
//.........这里部分代码省略.........
// 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
Expect(page.Find("#popup_confirm").Click()).To(Succeed())
Expect(page.ConfirmPopup()).To(Succeed())
Expect(page.RunScript("return confirmed;", nil, &confirmed)).To(Succeed())
Expect(confirmed).To(BeTrue())
Expect(page.Find("#popup_confirm").Click()).To(Succeed())
Expect(page.CancelPopup()).To(Succeed())
Expect(page.RunScript("return confirmed;", nil, &confirmed)).To(Succeed())
Expect(confirmed).To(BeFalse())
})
By("interacting with prompt boxes", func() {
var promptText string
Expect(page.Find("#popup_prompt").Click()).To(Succeed())
Expect(page.EnterPopupText("banana")).To(Succeed())
Expect(page.ConfirmPopup()).To(Succeed())
Expect(page.RunScript("return promptText;", nil, &promptText)).To(Succeed())
Expect(promptText).To(Equal("banana"))
})
})
}
It("should support manipulating and retrieving cookies", func() {
Expect(page.SetCookie(&http.Cookie{Name: "webdriver-test-cookie", Value: "webdriver value"})).To(Succeed())
cookies, err := page.GetCookies()
Expect(err).NotTo(HaveOccurred())
cookieNames := []string{cookies[0].Name, cookies[1].Name}
Expect(cookieNames).To(ConsistOf("webdriver-test-cookie", "browser-test-cookie"))
Expect(page.DeleteCookie("browser-test-cookie")).To(Succeed())
Expect(page.GetCookies()).To(HaveLen(1))
Expect(page.ClearCookies()).To(Succeed())
Expect(page.GetCookies()).To(HaveLen(0))
})
})
})
}
示例3: testPage
//.........这里部分代码省略.........
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
Expect(page.Find("#popup_confirm").Click()).To(Succeed())
Expect(page.ConfirmPopup()).To(Succeed())
Expect(page.RunScript("return confirmed;", nil, &confirmed)).To(Succeed())
Expect(confirmed).To(BeTrue())
Expect(page.Find("#popup_confirm").Click()).To(Succeed())
Expect(page.CancelPopup()).To(Succeed())
Expect(page.RunScript("return confirmed;", nil, &confirmed)).To(Succeed())
Expect(confirmed).To(BeFalse())
})
By("interacting with prompt boxes", func() {
var promptText string
Expect(page.Find("#popup_prompt").Click()).To(Succeed())
Expect(page.EnterPopupText("banana")).To(Succeed())
Expect(page.ConfirmPopup()).To(Succeed())
Expect(page.RunScript("return promptText;", nil, &promptText)).To(Succeed())
Expect(promptText).To(Equal("banana"))
})
})
}
It("should support manipulating and retrieving cookies", func() {