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


Golang Page.All方法代码示例

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


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

示例1: getLastPost

func getLastPost(page *agouti.Page) *agouti.Selection {
	posts := page.All("#chat .message")
	postsCount, err := posts.Count()
	if err != nil {
		panic(err)
	}

	return posts.At(postsCount - 1)
}
开发者ID:roblaszczak,项目名称:simple-go-chat,代码行数:9,代码来源:use_chat_test.go

示例2: 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

示例3: 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

示例4:

		BeforeEach(func() {
			var err error
			page, err = agoutiDriver.NewPage()
			Expect(err).NotTo(HaveOccurred())
			Expect(page.Navigate("http://localhost:8080/#/phones/nexus-s")).To(Succeed())
		})

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

		It("should display nexus-s page", func() {
			Eventually(page.Find("h1")).Should(HaveText("Nexus S"))
		})

		It("should display the first phone image as the main phone image", func() {
			image := page.All("img.phone").At(0)
			Eventually(image).Should(HaveAttribute("ng-src", "static/img/phones/nexus-s.0.jpg"))
		})

		It("should swap main image if a thumbnail image is clicked on", func() {
			images := page.All("ul.phone-thumbs").AllByName("image-see")
			Expect(images.At(2).Click()).To(Succeed())
			Eventually(page.All("img.phone").At(2)).Should(HaveAttribute("ng-src", "static/img/phones/nexus-s.2.jpg"))
			Expect(images.At(0).Click()).To(Succeed())
			Eventually(page.All("img.phone").At(0)).Should(HaveAttribute("ng-src", "static/img/phones/nexus-s.0.jpg"))
		})
	})
})
开发者ID:Jackgris,项目名称:angularjsAndTestWithGo,代码行数:29,代码来源:angular_test.go

示例5:

					resourceVersions = append(resourceVersions, atc.Version{"version": strconv.Itoa(i)})
				}

				pipelineDB.SaveResourceVersions(resourceConfig, resourceVersions)
			})

			It("there is pagination", func() {
				// homepage -> resource detail
				Expect(page.Navigate(homepage())).To(Succeed())
				Eventually(page.FindByLink("resource-name")).Should(BeFound())
				Expect(page.FindByLink("resource-name").Click()).To(Succeed())

				// resource detail -> paused resource detail
				Expect(page).Should(HaveURL(withPath("/resources/resource-name")))
				Expect(page.Find("h1")).To(HaveText("resource-name"))
				Expect(page.All(".pagination").Count()).Should(Equal(2))
				Expect(page.Find(".resource-versions")).Should(BeFound())
				Expect(page.All(".resource-versions li").Count()).Should(Equal(100))

				Expect(page.Find(".pagination .fa-arrow-left")).ShouldNot(BeFound())
				Expect(page.First(".pagination .fa-arrow-right").Click()).To(Succeed())
				Expect(page.All(".resource-versions li").Count()).Should(Equal(4))

				Expect(page.Find(".pagination .fa-arrow-right")).ShouldNot(BeFound())
				Expect(page.First(".pagination .fa-arrow-left").Click()).To(Succeed())
				Expect(page.All(".resource-versions li").Count()).Should(Equal(100))

			})
		})

		Context("with less than 100 resource versions", func() {
开发者ID:utako,项目名称:atc,代码行数:31,代码来源:resource_pagination_test.go

示例6:

			user.OpenOrgMenuOn(page).ClickMarketplaceLink()
		})

		By("showing the user a table with all the services", func() {
			DelayForRendering()
			Expect(page.Find("#service-name-heading")).To(BeFound())
			Expect(page.Find("#service-description-heading")).To(BeFound())
			Expect(page.Find("#service-date-created-heading")).To(BeFound())
			Expect(page.First(".service-name-data")).To(BeFound())
			Expect(page.First(".service-description-data")).To(BeFound())
			Expect(page.First(".service-date-created-data")).To(BeFound())
		})

		By("allowing the user to search for a service", func() {
			DelayForRendering()
			rowCountPreSearch, _ := page.All(".service-name-data").Count()
			Expect(page.Find("#serviceSearch").Fill("zzzzzzzzz1111zzz")).To(Succeed())
			Expect(page.All(".service-name-data")).NotTo(HaveCount(rowCountPreSearch))
		})
	})

	AfterEach(func() {
		// Logout user
		user.LogoutOf(page)
		// Destroy the page
		Expect(page.Destroy()).To(Succeed())
		// Close the server.
		server.Close()
	})
})
开发者ID:ArthurHlt,项目名称:cg-deck,代码行数:30,代码来源:app_structure_test.go

示例7:

					for i := 1; i < 103; i++ {
						build, err := pipelineDB.CreateJobBuild("job-name")
						Expect(err).NotTo(HaveOccurred())
						testBuilds = append(testBuilds, build)
					}
				})

				It("can have paginated results", func() {
					// homepage -> job detail w/build info
					Expect(page.Navigate(homepage())).To(Succeed())
					// we will need to authenticate later to prove it is working for our page
					Authenticate(page, "admin", "password")
					Eventually(page.FindByLink("job-name")).Should(BeFound())
					Expect(page.FindByLink("job-name").Click()).To(Succeed())

					Expect(page.All("#builds li").Count()).Should(Equal(103))

					// job detail w/build info -> job detail
					Eventually(page.Find("h1 a")).Should(BeFound())
					Expect(page.Find("h1 a").Click()).To(Succeed())
					Eventually(page).Should(HaveURL(withPath("jobs/job-name")))
					Expect(page.All(".js-build").Count()).Should(Equal(100))

					Expect(page.Find(".pagination .fa-arrow-left")).ShouldNot(BeFound())
					Expect(page.First(".pagination .fa-arrow-right").Click()).To(Succeed())
					Eventually(page.All(".js-build").Count).Should(Equal(3))

					Expect(page.Find(".pagination .fa-arrow-right")).ShouldNot(BeFound())
					Expect(page.First(".pagination .fa-arrow-left").Click()).To(Succeed())
					Eventually(page.All(".js-build").Count).Should(Equal(100))
				})
开发者ID:ACPK,项目名称:atc,代码行数:31,代码来源:job_builds_test.go

示例8:

					for i := 1; i < 103; i++ {
						build, err := pipelineDB.CreateJobBuild("job-name")
						Expect(err).NotTo(HaveOccurred())
						testBuilds = append(testBuilds, build)
					}
				})

				It("can have paginated results", func() {
					// homepage -> job detail w/build info
					Expect(page.Navigate(homepage())).To(Succeed())
					// we will need to authenticate later to prove it is working for our page
					Authenticate(page, "admin", "password")
					Eventually(page.FindByLink("job-name")).Should(BeFound())
					Expect(page.FindByLink("job-name").Click()).To(Succeed())

					Eventually(page.All("#builds li").Count).Should(Equal(103))

					// job detail w/build info -> job detail
					Eventually(page.Find("h1 a")).Should(BeFound())
					Expect(page.Find("h1 a").Click()).To(Succeed())
					Eventually(page).Should(HaveURL(withPath("jobs/job-name")))
					Eventually(page.All(".js-build").Count).Should(Equal(100))

					Expect(page.First(".pagination .disabled .fa-arrow-left")).Should(BeFound())
					Expect(page.First(".pagination .fa-arrow-right").Click()).To(Succeed())
					Eventually(page.All(".js-build").Count).Should(Equal(3))

					Expect(page.First(".pagination .disabled .fa-arrow-right")).Should(BeFound())
					Expect(page.First(".pagination .fa-arrow-left").Click()).To(Succeed())
					Eventually(page.All(".js-build").Count).Should(Equal(100))
				})
开发者ID:pcfdev-forks,项目名称:atc,代码行数:31,代码来源:job_builds_test.go


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