當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Page.FindByName方法代碼示例

本文整理匯總了Golang中github.com/sclevine/agouti.Page.FindByName方法的典型用法代碼示例。如果您正苦於以下問題:Golang Page.FindByName方法的具體用法?Golang Page.FindByName怎麽用?Golang Page.FindByName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/sclevine/agouti.Page的用法示例。


在下文中一共展示了Page.FindByName方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: LoginTo

func (u User) LoginTo(page *agouti.Page) {
	Expect(page.Navigate(u.testEnvVars.Hostname)).To(Succeed())
	Expect(page.Find("#login-btn").Click()).To(Succeed())
	Expect(page).To(HaveURL(u.testEnvVars.LoginURL + "login"))
	Expect(page.FindByName("username").Fill(u.username)).To(Succeed())
	Expect(page.FindByName("password").Fill(u.password)).To(Succeed())
	Expect(page.FindByButton("Sign in").Click()).To(Succeed())
	Expect(page).To(HaveURL(u.testEnvVars.Hostname + "/#/dashboard"))
}
開發者ID:ArthurHlt,項目名稱:cg-deck,代碼行數:9,代碼來源:user.go

示例2: LoginTo

func (u User) LoginTo(page *agouti.Page) {
	Expect(page.Navigate(u.testEnvVars.Hostname + "/#/")).To(Succeed())
	var loginLink = page.First(".test-login")
	Eventually(loginLink).Should(BeFound())
	Expect(loginLink.Click()).To(Succeed())
	Eventually(page).Should(HaveURL(u.testEnvVars.LoginURL + "login"))
	Expect(page.FindByName("username").Fill(u.username)).To(Succeed())
	Expect(page.FindByName("password").Fill(u.password)).To(Succeed())
	Expect(page.FindByButton("Sign in").Click()).To(Succeed())
	Eventually(page.FindByButton("Authorize").Click())
	Eventually(page).Should(HaveURL(u.testEnvVars.Hostname + "/#/dashboard"))
}
開發者ID:18F,項目名稱:cg-dashboard,代碼行數:12,代碼來源:user.go

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

示例4:

			Expect(page.Navigate(testEnvVars.Hostname + "/#/dashboard")).To(Succeed())
			Expect(page).To(HaveURL(testEnvVars.Hostname + "/#/"))
		})

	})

	It("should manage user authentication", func() {
		By("directing the user to a landing page", func() {
			Expect(page.Navigate(testEnvVars.Hostname)).To(Succeed())
		})

		By("allowing the user to click the login button and redirected to fill out the login form and submit it", func() {
			delayForRendering()
			Eventually(Expect(page.Find("#login-btn").Click()).To(Succeed()))
			Eventually(Expect(page).To(HaveURL(testEnvVars.LoginURL + "/login")))
			Expect(page.FindByName("username").Fill(testEnvVars.Username)).To(Succeed())
			Expect(page.FindByName("password").Fill(testEnvVars.Password)).To(Succeed())
			Expect(page.FindByButton("Sign in").Click()).To(Succeed())
			Expect(page).To(HaveURL(testEnvVars.Hostname + "/#/dashboard"))
		})

		/*
			By("allowing the user to log out", func() {
				Expect(page.Find("#logout").Click()).To(Succeed())
				Expect(page).To(HavePopupText("Are you sure?"))
				Expect(page.ConfirmPopup()).To(Succeed())
				Eventually(page).Should(HaveTitle("Login"))
			})
		*/
	})
開發者ID:goodnightjj,項目名稱:cf-deck,代碼行數:30,代碼來源:user_login_test.go

示例5:

		BeforeEach(func() {
			var err error
			page, err = agoutiDriver.NewPage()
			Expect(err).NotTo(HaveOccurred())
		})

		AfterEach(func() {
			Expect(page.Destroy()).To(Succeed())
		})
		It("provide a web interface to the API", func() {
			By("having a root page", func() {
				Expect(page.Navigate("http://" + address)).To(Succeed())
			})

			By("allowing the user to fill out the form and run a simulation", func() {
				Eventually(page.FindByName("NumHosts")).Should(BeFound())
				Expect(page.FindByName("NumHosts").Fill("100")).To(Succeed())
				Expect(page.FindByName("NumApps").Fill("300")).To(Succeed())
				Expect(page.FindByName("MeanInstancesPerApp").Fill("5")).To(Succeed())
				Expect(page.FindByButton("Simulate").Click()).To(Succeed())
			})

			By("showing a histogram of app sizes", func() {
				Eventually(page.HTML).Should(ContainSubstring(`Size (instances)`))
				Eventually(page.HTML).Should(ContainSubstring(`40</text>`)) // tick mark on y axis
			})
		})
	})

})
開發者ID:rosenhouse,項目名稱:cnsim,代碼行數:30,代碼來源:acceptance_test.go

示例6:

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

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

		It("should filter the phone list as a user types into the search box", func() {

			phonesInList := page.Find("ul.phones").All("li")
			query := page.FindByName("query")

			Eventually(phonesInList).Should(HaveCount(20))
			Expect(query.Fill("nexus")).To(Succeed())
			Eventually(phonesInList).Should(HaveCount(1))
			Expect(query.Fill("motorola")).To(Succeed()) // Note: Fill clears automatically
			Eventually(phonesInList).Should(HaveCount(8))
		})

		It("should be possible to control phone order via the drop down select box", func() {

			phoneNameColumn := page.Find("ul.phones").AllByName("phone-name")
			query := page.FindByName("query")
			selected := page.Find("select")

			Expect(query.Fill("tablet")).To(Succeed()) //let's narrow the dataset to make the test assertions shorter
開發者ID:Jackgris,項目名稱:angularjsAndTestWithGo,代碼行數:31,代碼來源:angular_test.go

示例7:

		var err error
		page, err = agoutiDriver.NewPage()
		Expect(err).NotTo(HaveOccurred())
	})

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

	It("should manage user authentication", func() {
		By("redirecting the user to the login form from the webapp page", func() {
			Expect(page.Navigate(AcceptanceSettings("webappUrl"))).To(Succeed())
		})

		By("allowing the user to fill out the login form and submit it", func() {
			Eventually(page.FindByName("email")).Should(BeFound())
			Expect(page.FindByName("email").Fill(AcceptanceSettings("email"))).To(Succeed())
			Expect(page.FindByName("password").Fill(AcceptanceSettings("password"))).To(Succeed())
			Expect(page.FirstByButton("Get Access").Submit()).To(Succeed())
		})

		By("allowing the user to view its data", func() {
			Eventually(page.Find("#user-context")).Should(BeFound())
			Expect(page.Find("#user-context").Click()).To(Succeed())
			Expect(page.Find(".user-submenu")).To(BeVisible())
			Expect(page.Find(".user-submenu .submenu-data p").Text()).To(Equal("Signed in as\nAcceptance Tests"))
		})

		By("allowing the user to logout", func() {
			Eventually(page.Find("#user-context")).Should(BeFound())
			Expect(page.Find("#user-context").Click()).To(Succeed())
開發者ID:earaujoassis,項目名稱:space,代碼行數:31,代碼來源:acceptance_user_login_test.go


注:本文中的github.com/sclevine/agouti.Page.FindByName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。