当前位置: 首页>>代码示例>>Golang>>正文


Golang Page.DoubleClick方法代码示例

本文整理汇总了Golang中github.com/sclevine/agouti.Page.DoubleClick方法的典型用法代码示例。如果您正苦于以下问题:Golang Page.DoubleClick方法的具体用法?Golang Page.DoubleClick怎么用?Golang Page.DoubleClick使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/sclevine/agouti.Page的用法示例。


在下文中一共展示了Page.DoubleClick方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: testPage


//.........这里部分代码省略.........
					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))
		})

		It("should support resetting the page", func() {
			Expect(page.SetCookie(&http.Cookie{Name: "webdriver-test-cookie", Value: "webdriver value"})).To(Succeed())
			Expect(page.GetCookies()).To(HaveLen(2))

			Expect(page.RunScript("localStorage.setItem('some-local-storage-key', 'some-local-storage-value');", nil, nil)).To(Succeed())
			var localStorageTest string
			Expect(page.RunScript("return localStorage.getItem('some-local-storage-key')", nil, &localStorageTest)).To(Succeed())
			Expect(localStorageTest).To(Equal("some-local-storage-value"))

			Expect(page.RunScript("sessionStorage.setItem('some-session-storage-key', 'some-session-storage-value');", nil, nil)).To(Succeed())
			var sessionStorageTest string
			Expect(page.RunScript("return sessionStorage.getItem('some-session-storage-key')", nil, &sessionStorageTest)).To(Succeed())
			Expect(sessionStorageTest).To(Equal("some-session-storage-value"))

			Expect(page.Find("#popup_alert").Click()).To(Succeed())

			Expect(page.Reset()).To(Succeed())

			By("navigating to about:blank", func() {
				Expect(page.URL()).To(Equal("about:blank"))
			})

			Expect(page.Navigate(server.URL)).To(Succeed())

			By("deleting all cookies for the current domain", func() {
				Expect(page.GetCookies()).To(HaveLen(1))
			})

			By("deleting local storage for the current domain", func() {
				var localStorageTest string
				Expect(page.RunScript("return localStorage.getItem('some-local-storage-key');", nil, &localStorageTest)).To(Succeed())
				Expect(localStorageTest).To(BeEmpty())
			})

			By("deleting session storage for the current domain", func() {
				var sessionStorageTest string
				Expect(page.RunScript("return sessionStorage.getItem('some-session-storage-key');", nil, &sessionStorageTest)).To(Succeed())
				Expect(sessionStorageTest).To(BeEmpty())
			})

			By("allowing reset to be called multiple times", func() {
				Expect(page.Reset()).To(Succeed())
				Expect(page.Reset()).To(Succeed())
				Expect(page.Navigate(server.URL)).To(Succeed())
			})
		})

		It("should support various mouse events", func() {
			checkbox := page.Find("#some_checkbox")

			By("moving from the disabled checkbox a regular checkbox", func() {
				disabledCheckbox := page.Find("#some_disabled_checkbox")
				Expect(disabledCheckbox.MouseToElement())
				Expect(page.MoveMouseBy(-24, 0)).To(Succeed())

				// NOTE: Firefox does not move the mouse by an offset correctly
				if browserName == "Firefox" {
					Expect(checkbox.MouseToElement())
				}
			})

			By("single clicking on a checkbox", func() {
				Expect(page.Click(agouti.SingleClick, agouti.LeftButton)).To(Succeed())
				Expect(checkbox).To(BeSelected())
			})

			By("holding and releasing a click on a checkbox", func() {
				Expect(page.Click(agouti.HoldClick, agouti.LeftButton)).To(Succeed())
				Expect(page.Click(agouti.ReleaseClick, agouti.LeftButton)).To(Succeed())
				Expect(checkbox).NotTo(BeSelected())
			})

			By("moving the mouse pointer and double clicking", func() {
				doubleClick := page.Find("#double_click")
				Expect(doubleClick.MouseToElement()).To(Succeed())
				Expect(page.DoubleClick()).To(Succeed())
				Expect(doubleClick).To(HaveText("double-click success"))
			})
		})
	})
}
开发者ID:oneumyvakin,项目名称:agouti,代码行数:101,代码来源:page_test.go


注:本文中的github.com/sclevine/agouti.Page.DoubleClick方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。