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


Golang Page.Size方法代码示例

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


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

示例1: testSelection

func testSelection(browserName string, newPage pageFunc) {
	Describe("selection test for "+browserName, func() {
		var (
			page      *agouti.Page
			server    *httptest.Server
			submitted bool
		)

		BeforeEach(func() {
			server = httptest.NewServer(http.HandlerFunc(func(response http.ResponseWriter, request *http.Request) {
				if request.Method == "POST" {
					submitted = true
				}
				html, _ := ioutil.ReadFile("test_page.html")
				response.Write(html)
			}))

			var err error
			page, err = newPage()
			Expect(err).NotTo(HaveOccurred())

			Expect(page.Size(640, 480)).To(Succeed())
			Expect(page.Navigate(server.URL)).To(Succeed())
		})

		AfterEach(func() {
			Expect(page.Destroy()).To(Succeed())
			server.Close()
		})

		It("should support asserting on element identity", func() {
			By("asserting on an element's existence", func() {
				Expect(page.Find("header")).To(BeFound())
				Expect(page.Find("header")).To(HaveCount(1))
				Expect(page.Find("not-a-header")).NotTo(BeFound())
			})

			By("comparing two selections for equality", func() {
				Expect(page.Find("#some_element")).To(EqualElement(page.FindByXPath("//div[@class='some-element']")))
				Expect(page.Find("#some_element")).NotTo(EqualElement(page.Find("header")))
			})
		})

		It("should support moving the mouse pointer over a selected element", func() {
			Expect(page.Find("#some_checkbox").MouseToElement()).To(Succeed())
			Expect(page.Click(agouti.SingleClick, agouti.LeftButton)).To(Succeed())
			Expect(page.Find("#some_checkbox")).To(BeSelected())
		})

		It("should support selecting elements", func() {
			By("finding an element by selection index", func() {
				Expect(page.All("option").At(0)).To(HaveText("first option"))
				Expect(page.All("select").At(1).First("option")).To(HaveText("third option"))
			})

			By("finding an element by chained selectors", func() {
				Expect(page.Find("header").Find("h1")).To(HaveText("Title"))
				Expect(page.Find("header").FindByXPath("//h1")).To(HaveText("Title"))
			})

			By("finding an element by link text", func() {
				Expect(page.FindByLink("Click Me").Attribute("href")).To(HaveSuffix("#new_page"))
			})

			By("finding an element by label text", func() {
				Expect(page.FindByLabel("Some Label")).To(HaveAttribute("value", "some labeled value"))
				Expect(page.FindByLabel("Some Container Label")).To(HaveAttribute("value", "some embedded value"))
			})

			By("finding an element by button text", func() {
				Expect(page.FindByButton("Some Button")).To(HaveAttribute("name", "some button name"))
				Expect(page.FindByButton("Some Input Button")).To(HaveAttribute("type", "button"))
				Expect(page.FindByButton("Some Submit Button")).To(HaveAttribute("type", "submit"))
			})

			By("finding an element by name attibute", func() {
				Expect(page.FindByName("some button name")).To(HaveAttribute("name", "some button name"))
			})

			By("finding multiple elements", func() {
				Expect(page.All("select").All("option")).To(BeVisible())
				Expect(page.All("h1,h2")).NotTo(BeVisible())
			})
		})

		It("should support retrieving element properties", func() {
			By("asserting on element text", func() {
				Expect(page.Find("header")).To(HaveText("Title"))
				Expect(page.Find("header")).NotTo(HaveText("Not-Title"))
				Expect(page.Find("header")).To(MatchText("T.+e"))
				Expect(page.Find("header")).NotTo(MatchText("X.+e"))
			})

			By("asserting on whether elements are active", func() {
				Expect(page.Find("#labeled_field")).NotTo(BeActive())
				Expect(page.Find("#labeled_field").Click()).To(Succeed())
				Expect(page.Find("#labeled_field")).To(BeActive())
			})

			By("asserting on element attributes", func() {
//.........这里部分代码省略.........
开发者ID:oneumyvakin,项目名称:agouti,代码行数:101,代码来源:selection_test.go

示例2: itShouldBehaveLikeAPage

func itShouldBehaveLikeAPage(name string, newPage pageFunc) {
	Describe("integration test for "+name, func() {
		var (
			page      *agouti.Page
			server    *httptest.Server
			submitted bool
		)

		BeforeEach(func() {
			server = httptest.NewServer(http.HandlerFunc(func(response http.ResponseWriter, request *http.Request) {
				if request.Method == "POST" {
					submitted = true
				}
				html, _ := ioutil.ReadFile("test_page.html")
				response.Write(html)
			}))

			var err error
			page, err = newPage()
			Expect(err).NotTo(HaveOccurred())

			Expect(page.Size(640, 480)).To(Succeed())
			Expect(page.Navigate(server.URL)).To(Succeed())
		})

		AfterEach(func() {
			Expect(page.Destroy()).To(Succeed())
			server.Close()
		})

		Describe("Selection interactions", func() {
			It("should support asserting on element identity", func() {
				By("asserting on an element's existence", func() {
					Expect(page.Find("header")).To(BeFound())
					Expect(page.Find("header")).To(HaveCount(1))
					Expect(page.Find("not-a-header")).NotTo(BeFound())
				})

				By("comparing two selections for equality", func() {
					Expect(page.Find("#some_element")).To(EqualElement(page.FindByXPath("//div[@class='some-element']")))
				})
			})

			It("should support selecting elements", func() {
				By("finding an element by selection index", func() {
					Expect(page.All("option").At(0)).To(HaveText("first option"))
					Expect(page.All("select").At(1).First("option")).To(HaveText("third option"))
				})

				By("finding an element by chained selectors", func() {
					Expect(page.Find("header").Find("h1")).To(HaveText("Title"))
					Expect(page.Find("header").FindByXPath("//h1")).To(HaveText("Title"))
				})

				By("finding an element by link text", func() {
					Expect(page.FindByLink("Click Me").Attribute("href")).To(HaveSuffix("#new_page"))
				})

				By("finding an element by label text", func() {
					Expect(page.FindByLabel("Some Label")).To(HaveAttribute("value", "some labeled value"))
					Expect(page.FindByLabel("Some Container Label")).To(HaveAttribute("value", "some embedded value"))
				})

				By("finding an element by button text", func() {
					Expect(page.FindByButton("Some Button")).To(HaveAttribute("name", "some button name"))
					Expect(page.FindByButton("Some Input Button")).To(HaveAttribute("type", "button"))
					Expect(page.FindByButton("Some Submit Button")).To(HaveAttribute("type", "submit"))
				})

				By("finding an element by class", func() {
					Expect(page.FindByClass("some-element")).To(HaveAttribute("id", "some_element"))
				})

				By("finding an element by ID", func() {
					Expect(page.FindByID("some_element")).To(HaveAttribute("class", "some-element"))
				})

				By("finding multiple elements", func() {
					Expect(page.All("select").All("option")).To(BeVisible())
					Expect(page.All("h1,h2")).NotTo(BeVisible())
				})
			})

			It("should support retrieving element properties", func() {
				By("asserting on element text", func() {
					Expect(page.Find("header")).To(HaveText("Title"))
					Expect(page.Find("header")).NotTo(HaveText("Not-Title"))
					Expect(page.Find("header")).To(MatchText("T.+e"))
					Expect(page.Find("header")).NotTo(MatchText("X.+e"))
				})

				By("asserting on whether elements are active", func() {
					Expect(page.Find("#labeled_field")).NotTo(BeActive())
					Expect(page.Find("#labeled_field").Click()).To(Succeed())
					Expect(page.Find("#labeled_field")).To(BeActive())
				})

				By("asserting on element attributes", func() {
					Expect(page.Find("#some_checkbox")).To(HaveAttribute("type", "checkbox"))
				})
//.........这里部分代码省略.........
开发者ID:queran,项目名称:agouti,代码行数:101,代码来源:integration_test.go

示例3: testPage

func testPage(browserName string, newPage pageFunc) {
	Describe("page test for "+browserName, func() {
		var (
			page   *agouti.Page
			server *httptest.Server
		)

		BeforeEach(func() {
			server = httptest.NewServer(http.HandlerFunc(func(response http.ResponseWriter, request *http.Request) {
				html, _ := ioutil.ReadFile("test_page.html")
				response.Write(html)
			}))

			var err error
			page, err = newPage()
			Expect(err).NotTo(HaveOccurred())

			Expect(page.Size(640, 480)).To(Succeed())
			Expect(page.Navigate(server.URL)).To(Succeed())
		})

		AfterEach(func() {
			Expect(page.Destroy()).To(Succeed())
			server.Close()
		})

		It("should support retrieving page properties", func() {
			Expect(page).To(HaveTitle("Page Title"))
			Expect(page).To(HaveURL(server.URL + "/"))
			Expect(page.HTML()).To(ContainSubstring("<h1>Title</h1>"))
		})

		It("should support JavaScript", func() {
			By("waiting for page JavaScript to take effect", func() {
				Expect(page.Find("#some_element")).NotTo(HaveText("some text"))
				Eventually(page.Find("#some_element"), "4s").Should(HaveText("some text"))
				Consistently(page.Find("#some_element")).Should(HaveText("some text"))
			})

			// NOTE: disabled due to recent Firefox regression with passing args
			if browserName != "Firefox" {
				By("executing provided JavaScript", func() {
					arguments := map[string]interface{}{"elementID": "some_element"}
					var result string
					Expect(page.RunScript("return document.getElementById(elementID).innerHTML;", arguments, &result)).To(Succeed())
					Expect(result).To(Equal("some text"))
				})
			}
		})

		It("should support taking screenshots", func() {
			Expect(page.Screenshot(".test.screenshot.png")).To(Succeed())
			defer os.Remove(".test.screenshot.png")
			file, _ := os.Open(".test.screenshot.png")
			_, err := png.Decode(file)
			Expect(err).NotTo(HaveOccurred())
		})

		It("should support links and navigation", func() {
			By("clicking on a link", func() {
				Expect(page.FindByLink("Click Me").Click()).To(Succeed())
				Expect(page.URL()).To(ContainSubstring("#new_page"))
			})

			By("navigating through browser history", func() {
				Expect(page.Back()).To(Succeed())
				Expect(page.URL()).NotTo(ContainSubstring("#new_page"))
				Expect(page.Forward()).To(Succeed())
				Expect(page.URL()).To(ContainSubstring("#new_page"))
			})

			By("refreshing the page", func() {
				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"))
				})
//.........这里部分代码省略.........
开发者ID:oneumyvakin,项目名称:agouti,代码行数:101,代码来源:page_test.go

示例4:

	"newUserEmail":         "[email protected]",
	"newUserPassword":      "testpassword",
	"fixtureUserEmail":     "[email protected]",
	"fixtureUserPassword":  "test",
	"fixtureAdminEmail":    "[email protected]",
	"fixtureAdminPassword": "test",
}

var _ = Describe("CasGo", func() {
	var page *agouti.Page

	BeforeEach(func() {
		page, err := agoutiDriver.NewPage()
		Expect(err).NotTo(HaveOccurred())
		page.Navigate(testHTTPServer.URL)
		page.Size(640, 480)
	})

	AfterEach(func() {
		page.Destroy()
	})

	It("Finding the expected title on the index page", func() {
		Expect(page).To(HaveTitle("CasGo"))
	})

	It("Find the expected title on the login page", func() {
		page.Navigate(testHTTPServer.URL + "/login")
		expectedTitle := testCASServer.Config["companyName"] + " - Login"
		Expect(page.Find("#page-title")).To(HaveText(expectedTitle))
	})
开发者ID:jostyee,项目名称:casgo,代码行数:31,代码来源:integration_test.go

示例5: testMobile

func testMobile(browserName string, newPage pageFunc) {
	Describe("mobile test for "+browserName, func() {
		var (
			page   *agouti.Page
			server *httptest.Server
		)

		BeforeEach(func() {
			server = httptest.NewServer(http.HandlerFunc(func(response http.ResponseWriter, request *http.Request) {
				html, _ := ioutil.ReadFile("mobile_test_page.html")
				response.Write(html)
			}))

			var err error
			page, err = newPage()
			Expect(err).NotTo(HaveOccurred())

			Expect(page.Size(640, 480)).To(Succeed())
			port := strings.Split(server.URL, ":")[2]
			Expect(page.Navigate("http://10.0.2.2:" + port)).To(Succeed())
		})

		AfterEach(func() {
			Expect(page.Destroy()).To(Succeed())
			server.Close()
		})

		It("should support various touch events", func() {
			touch := page.Find("#touch")
			message := page.Find("#message")

			By("performing tap actions", func() {
				Expect(touch.Tap(agouti.SingleTap)).To(Succeed())
				Eventually(message).Should(HaveText("event: start with 1 end with 0"))
				Expect(page.Refresh()).To(Succeed())
				Expect(touch.Tap(agouti.DoubleTap)).To(Succeed())
				Eventually(message).Should(HaveText("event: start with 1 end with 0 start with 1 end with 0"))
			})

			By("performing touch actions", func() {
				Expect(page.Refresh()).To(Succeed())
				Expect(touch.Touch(agouti.HoldFinger)).To(Succeed())
				Eventually(message).Should(HaveText("event: start with 1"))
				Expect(page.Refresh()).To(Succeed())
				Expect(touch.Touch(agouti.HoldFinger)).To(Succeed())
				Expect(touch.Touch(agouti.ReleaseFinger)).To(Succeed())
				Eventually(message).Should(HaveText("event: start with 1 end with 0"))
			})

			By("performing a flick", func() {
				Expect(page.Refresh()).To(Succeed())
				Expect(touch.FlickFinger(10, 10, 10)).To(Succeed())
				Eventually(message).Should(HaveText("event: start with 1 end with 0"))
			})

			By("performing a finger scroll", func() {
				Expect(page.Refresh()).To(Succeed())
				Expect(touch.ScrollFinger(40, 50)).To(Succeed())
				Eventually(message).Should(MatchText("event: scroll left [45][0-9] scroll top [56][0-9]"))
			})
		})
	})
}
开发者ID:oneumyvakin,项目名称:agouti,代码行数:63,代码来源:mobile_test.go


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