本文整理汇总了Golang中github.com/sclevine/agouti.Page.Find方法的典型用法代码示例。如果您正苦于以下问题:Golang Page.Find方法的具体用法?Golang Page.Find怎么用?Golang Page.Find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/sclevine/agouti.Page
的用法示例。
在下文中一共展示了Page.Find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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"))
}
示例2:
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))
})
})
It("can view resource information of a job build", func() {
示例3:
var _ = Describe("ListJobs", func() {
var page *agouti.Page
BeforeEach(func() {
var err error
page, err = agoutiDriver.NewPage()
Expect(err).NotTo(HaveOccurred())
})
AfterEach(func() {
Expect(page.Destroy()).To(Succeed())
})
It("shows a list of jobs", func() {
By("root url redirects to jobs page", func() {
Expect(page.Navigate("http://localhost:3001")).To(Succeed())
Eventually(page.Find("a#newJob")).Should(BeFound())
})
By("creating a new job", func() {
pageobjects.NewListJobsPage(page).GoToCreateNewJob().CreateJob("Jerb", "echo hello", "busybox", "")
})
By("list includes the job on jobs page", func() {
Expect(page.Navigate("http://localhost:3001/jobs")).To(Succeed())
Eventually(page.Find(".job:first-of-type")).Should(MatchText(".*Jerb.*"))
})
})
})
示例4:
_, err = pipelineDBFactory.BuildWithTeamNameAndName(team.Name, "another-pipeline")
Expect(err).NotTo(HaveOccurred())
})
homeLink := ".js-groups li:nth-of-type(2) a"
defaultPipelineLink := ".js-pipelinesNav-list li:nth-of-type(1) a"
anotherPipelineLink := ".js-pipelinesNav-list li:nth-of-type(2) a"
anotherPipelineItem := ".js-pipelinesNav-list li:nth-of-type(2)"
It("can pause the pipelines", func() {
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.Find("#pipeline").Text).Should(ContainSubstring("some-job-name"))
Expect(page.Find(".js-pipelinesNav-toggle").Click()).To(Succeed())
Expect(page.Find(defaultPipelineLink)).To(HaveText("some-pipeline"))
Expect(page.Find(anotherPipelineLink)).To(HaveText("another-pipeline"))
Expect(page.Find(anotherPipelineLink).Click()).To(Succeed())
Eventually(page).Should(HaveURL(withPath("/pipelines/another-pipeline")))
Expect(page.Find(homeLink).Click()).To(Succeed())
Eventually(page).Should(HaveURL(withPath("/pipelines/another-pipeline")))
Expect(page.Find(".js-pipelinesNav-toggle").Click()).To(Succeed())
Eventually(page.Find(defaultPipelineLink)).Should(HaveText("some-pipeline"))
Eventually(page.Find("#pipeline").Text).Should(ContainSubstring("another-job-name"))
示例5:
},
}, true)
Ω(err).ShouldNot(HaveOccurred())
})
It("can view the resource information of a job build", 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())
// job detail w/build info -> job detail
Expect(page).Should(HaveURL(withPath(fmt.Sprintf("jobs/job-name/builds/%d", build.ID))))
Expect(page.Find("h1")).To(HaveText(fmt.Sprintf("job-name #%d", build.ID)))
Expect(page.Find("h1 a").Click()).To(Succeed())
Expect(page).Should(HaveURL(withPath("jobs/job-name")))
Expect(page.Find(".builds-list li").Count()).Should(Equal(1))
Expect(page.Find(".builds-list li:first-child a")).To(HaveText(fmt.Sprintf("#%d", build.ID)))
buildTimes, err := page.Find(".builds-list li:first-child .build-times").Text()
Ω(err).ShouldNot(HaveOccurred())
Expect(buildTimes).To(ContainSubstring("started"))
Expect(buildTimes).To(ContainSubstring("a few seconds ago"))
Expect(buildTimes).To(ContainSubstring("succeeded"))
Expect(buildTimes).To(ContainSubstring("a few seconds ago"))
Expect(buildTimes).To(ContainSubstring("duration"))
Expect(page.Find(".builds-list li:first-child .inputs")).Should(BeFound())
示例6:
server, testEnvVars = startServer()
// Create a fresh page to navigate.
page = createPage()
// Reset page
resetPage(page, testEnvVars)
// Create user
user = StartUserSessionWith(testEnvVars)
})
It("should show the login form if accessing privileged dashboard page without first logining in.", func() {
By("redirecting the user to the login form", func() {
Expect(page.Navigate(testEnvVars.Hostname + "/#/")).To(Succeed())
Expect(page.Find(".test-login")).Should(BeVisible())
})
})
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() {
user.LoginTo(page)
})
By("allowing the user to log out", func() {
Skip("Not implemented")
示例7:
It("should redirect users to login page if accessing privileged dashboard page without first logining in.", func() {
By("redirecting the user to the login form", func() {
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"))
})
*/
示例8:
Expect(err).NotTo(HaveOccurred())
page.SetImplicitWait(10000)
})
AfterEach(func() {
Expect(page.Destroy()).To(Succeed())
})
It("should be able to add an entry", func() {
By("redirecting the user to the page", func() {
Expect(page.Navigate("http://localhost:8083/")).To(Succeed())
Expect(page).To(HaveURL("http://localhost:8083/"))
})
By("loading the page completely", func() {
Eventually(page.Find(".form-control"), "10s").Should(BeFound())
Eventually(page.Find("#redis-resp"), "10s").ShouldNot(HaveText("Loading..."))
})
By("allowing the user to fill out the login form and submit it", func() {
Expect(page.Find(".form-control").Fill(salutations)).To(Succeed())
Expect(page.Find(".btn-primary").Click()).To(Succeed())
Eventually(page.Find("#redis-resp")).Should(HaveText("Sending..."))
})
By("allowing the user to see the text", func() {
Eventually(page.Find(".class-messages:last-of-type"), "10s").Should(HaveText(salutations))
})
})
})
示例9:
})
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())
Expect(page.Find(".user-submenu")).To(BeVisible())
Eventually(page.Find(".user-submenu ul.submenu a[href='/logout']")).Should(BeFound())
Expect(page.Find(".user-submenu ul.submenu a[href='/logout']").Click()).To(Succeed())
Eventually(page.FindByName("email")).Should(BeFound())
Eventually(page.FindByName("password")).Should(BeFound())
Eventually(page.FirstByButton("Get Access")).Should(BeFound())
})
示例10:
It("runs the job on the host OS", func() {})
})
It("creates and runs the new job", func() {
By("creating the new job using the specified docker image", func() {
pageobjects.NewListJobsPage(page).Visit().
GoToCreateNewJob().
CreateJob("Bob", "cat /etc/lsb-release", "ubuntu:14.04.3", "")
})
By("streaming the output from the job", func() {
expected := `.*DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=14.04
DISTRIB_CODENAME=trusty
DISTRIB_DESCRIPTION="Ubuntu 14.04.3 LTS".*`
Eventually(page.Find("#jobOutput")).Should(MatchText(expected))
})
By("indicating that the job ran successfully", func() {
Eventually(page.Find("#jobResult")).Should(HaveText("Success"))
})
By("indicating that the job is passing on job list page", func() {
pageobjects.NewListJobsPage(page).Visit()
Eventually(page.FindByLink("Bob")).Should(HaveAttribute("class", "passing"))
})
})
Context("when 2 builds are scheduled for a job", func() {
It("preserves build history", func() {
var showBuildPage *pageobjects.ShowBuildPage
示例11:
}, db.ConfigVersion(1), db.PipelineUnpaused)
Ω(err).ShouldNot(HaveOccurred())
pipelineDB, err = pipelineDBFactory.BuildDefault()
Ω(err).ShouldNot(HaveOccurred())
})
It("can view the resource", 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"))
Authenticate(page, "admin", "password")
Expect(page.Find(".js-resource .js-pauseUnpause").Click()).To(Succeed())
Eventually(page.Find(".header i.fa-play")).Should(BeFound())
page.Refresh()
Eventually(page.Find(".header i.fa-play")).Should(BeFound())
resource, err := pipelineDB.GetResource("resource-name")
Ω(err).ShouldNot(HaveOccurred())
err = pipelineDB.SetResourceCheckError(resource, errors.New("failed to foo the bar"))
Ω(err).ShouldNot(HaveOccurred())
示例12:
jobService.RunJobReturns(4, nil)
jobService.FindBuildReturns(build, nil)
Expect(page.Navigate(fmt.Sprintf("%s/jobs/new", server.URL))).To(Succeed())
pageobjects.NewNewJobPage(page).CreateJob("Alice", "bork bork", "user/image:tag", "some-repo.git")
Expect(jobService.SaveCallCount()).To(Equal(1))
})
By("redirecting to the build output page", func() {
Eventually(page).Should(HaveURL(fmt.Sprintf("%s/jobs/some-id/builds/4", server.URL)))
})
By("running job", func() {
Eventually(page.Find("#jobOutput")).Should(HaveText("boom!"))
Eventually(page.Find("#jobResult")).Should(HaveText("Success"))
Expect(jobService.RunJobCallCount()).To(Equal(1))
Expect(jobService.RunJobArgsForCall(0)).To(Equal("some-id"))
Expect(jobService.FindBuildCallCount()).To(Equal(1))
jobId, buildNumber := jobService.FindBuildArgsForCall(0)
Expect(jobId).To(Equal("some-id"))
Expect(buildNumber).To(Equal(4))
})
})
Context("when saving the job fails", func() {
BeforeEach(func() {
jobService.SaveReturns(errors.New("oh dear!"))
示例13:
server, testEnvVars = startServer()
// Create a fresh page to navigate.
page = createPage()
})
It("should show app structure for an authenticated user", func() {
// TODO remove skip once requirement is redone.
Skip("app page changed")
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())
Eventually(Expect(page).To(HaveURL(testEnvVars.Hostname + "/#/dashboard")))
})
By("allowing the user to click a dropdown menu labeled 'Organizations'", func() {
delayForRendering()
Expect(page.Find("#org-dropdown")).To(BeFound())
Expect(page.Find("#org-dropdown").Text()).To(Equal("Organization: Select one "))
Expect(page.Find("#org-dropdown").Click()).To(Succeed())
})
By("allowing the user to click on an organization in the dropdown menu", func() {
delayForRendering()
示例14:
Expect(err).NotTo(HaveOccurred())
page.SetImplicitWait(10000)
})
AfterEach(func() {
Expect(page.Destroy()).To(Succeed())
})
It("should give user feedback", func() {
By("go to homepage", func() {
Expect(page.Navigate("http://localhost:9102/")).To(Succeed())
Expect(page).To(HaveURL("http://localhost:9102/"))
})
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())
示例15: getLastPost
})
AfterEach(func() {
Expect(page.Destroy()).To(Succeed())
})
It("should communicate via chat", func() {
By("allowing the user to connect chat", func() {
Expect(page.Navigate("http://localhost:8080")).To(Succeed())
firstPostContent := getLastPost(page).Find(".content")
Expect(firstPostContent).To(MatchText("hello, anonymus_[0-9]{3}"))
})
By("allowing the user to send message", func() {
Expect(page.Find("[ng-model='message']").Fill("hello, biczez")).To(Succeed())
Expect(page.FindByButton("Send").Submit()).To(Succeed())
Expect(getLastPost(page).Find(".content")).To(HaveText("hello, biczez"))
})
})
})
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)
}