本文整理汇总了Golang中github.com/sclevine/agouti.Page类的典型用法代码示例。如果您正苦于以下问题:Golang Page类的具体用法?Golang Page怎么用?Golang Page使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Page类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: LogoutOf
func (u User) LogoutOf(page *agouti.Page) {
Expect(page.Navigate(u.testEnvVars.Hostname + "/v2/logout")).To(Succeed())
/*
Expect(page.Find("#logout-btn").Click()).To(Succeed())
Eventually(Expect(page).To(HaveURL(u.testEnvVars.LoginURL + "login")))
*/
}
开发者ID:18F,项目名称:cg-dashboard,代码行数:7,代码来源:user.go
示例2: 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
示例3: FindFirstVisibleOverlayButtonByText
func FindFirstVisibleOverlayButtonByText(text string, page *agouti.Page) *agouti.Selection {
allSelections := page.AllByButton(text)
allSelectionsCount, _ := allSelections.Count()
for i := 0; i < allSelectionsCount; i++ {
if visible, _ := allSelections.At(i).Visible(); visible {
return allSelections.At(i)
}
}
return nil
}
开发者ID:ArthurHlt,项目名称:cg-deck,代码行数:10,代码来源:util.go
示例4: 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
示例5: Authenticate
func Authenticate(page *agouti.Page, username, password string) {
header := fmt.Sprintf("%s:%s", username, password)
page.SetCookie(&http.Cookie{
Name: auth.CookieName,
Value: "Basic " + base64.StdEncoding.EncodeToString([]byte(header)),
})
// PhantomJS won't send the cookie on ajax requests if the page is not
// refreshed
page.Refresh()
}
开发者ID:pcfdev-forks,项目名称:atc,代码行数:12,代码来源:acceptance_suite_test.go
示例6: 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
示例7: TestSpec
func TestSpec(t *testing.T) {
Convey("UserRegister", t, func() {
var agoutiDriver *agouti.WebDriver
var page *agouti.Page
session, _ := mgo.Dial("localhost")
session.DB("TESTGoNuts").DropDatabase()
agoutiDriver = agouti.PhantomJS()
So(agoutiDriver.Start(), ShouldBeNil)
log.Println("Starting")
go StartMyApp(3232, "TESTGoNuts")
var err error
page, err = agoutiDriver.NewPage(agouti.Browser("chrome"))
So(err, ShouldBeNil)
Convey("User Registration page", func() {
Convey("when the user registration is reached", func() {
Convey("should see the page", func() {
So(page.Navigate("http://localhost:3232"), ShouldBeNil)
url, _ := page.URL()
So(url, ShouldEqual, "http://localhost:3232/")
})
})
})
Reset(func() {
So(page.Destroy(), ShouldBeNil)
So(agoutiDriver.Stop(), ShouldBeNil)
})
})
}
开发者ID:FanszHub,项目名称:test-site,代码行数:38,代码来源:Server_test.go
示例8:
import (
. "github.com/18F/cg-dashboard/acceptance/util"
. "github.com/18F/cg-dashboard/acceptance/views"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/sclevine/agouti"
. "github.com/sclevine/agouti/matchers"
"net/http/httptest"
)
var _ = Describe("UserLogin", func() {
var (
page *agouti.Page
server *httptest.Server
testEnvVars AcceptanceTestEnvVars
user User
)
testEnvVars = AcceptanceTestEnvVars{}
testEnvVars.LoadTestEnvVars()
BeforeEach(func() {
// Start a test server
server, testEnvVars = startServer()
// Create a fresh page to navigate.
page = createPage()
// Reset page
resetPage(page, testEnvVars)
开发者ID:18F,项目名称:cg-dashboard,代码行数:31,代码来源:user_login_test.go
示例9:
sqlDB = db.NewSQL(dbLogger, dbConn, bus)
pipelineDBFactory = db.NewPipelineDBFactory(dbLogger, dbConn, bus, sqlDB)
atcProcess, atcPort = startATC(atcBin, 1, true, BASIC_AUTH)
_, err := dbConn.Query(`DELETE FROM teams WHERE name = 'main'`)
Expect(err).NotTo(HaveOccurred())
})
AfterEach(func() {
ginkgomon.Interrupt(atcProcess)
Expect(dbConn.Close()).To(Succeed())
Expect(dbListener.Close()).To(Succeed())
})
Describe("pausing a job", 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())
})
homepage := func() string {
return fmt.Sprintf("http://127.0.0.1:%d/pipelines/%s", atcPort, atc.DefaultPipelineName)
}
开发者ID:pcfdev-forks,项目名称:atc,代码行数:30,代码来源:job_pausing_test.go
示例10: Screenshot
func Screenshot(page *agouti.Page) {
page.Screenshot("/tmp/screenshot.png")
}
开发者ID:pcfdev-forks,项目名称:atc,代码行数:3,代码来源:acceptance_suite_test.go
示例11: LogoutOf
func (u User) LogoutOf(page *agouti.Page) {
Expect(page.Find("#logout-btn").Click()).To(Succeed())
Eventually(Expect(page).To(HaveURL(u.testEnvVars.LoginURL + "login")))
}
开发者ID:ArthurHlt,项目名称:cg-deck,代码行数:4,代码来源:user.go
示例12: OpenDropdownOfOrgsOn
func (u User) OpenDropdownOfOrgsOn(page *agouti.Page) {
Eventually(page.Find("#orgs-dropdown-btn")).Should(BeVisible())
Expect(page.Find("#orgs-dropdown-btn").Click()).To(Succeed())
}
开发者ID:ArthurHlt,项目名称:cg-deck,代码行数:4,代码来源:user.go
示例13: OpenOrgMenuOn
func (u User) OpenOrgMenuOn(page *agouti.Page) OrgMenu {
Eventually(page.Find("#org-dropdown-btn")).Should(BeVisible())
Expect(page.Find("#org-dropdown-btn").Click()).To(Succeed())
return OrgMenu{page}
}
开发者ID:ArthurHlt,项目名称:cg-deck,代码行数:5,代码来源:user.go
示例14: resetPage
func resetPage(page *agouti.Page, testEnvVars AcceptanceTestEnvVars) {
page.Navigate(testEnvVars.Hostname + "/v2/logout")
page.Navigate(testEnvVars.Hostname)
}
开发者ID:18F,项目名称:cg-dashboard,代码行数:4,代码来源:cf_console_suite_test.go
示例15:
. "github.com/onsi/gomega"
"github.com/sclevine/agouti"
. "github.com/sclevine/agouti/matchers"
)
var INTEGRATION_TEST_DATA map[string]string = map[string]string{
"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"))
})
开发者ID:jostyee,项目名称:casgo,代码行数:31,代码来源:integration_test.go
示例16: 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
示例17: 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
示例18:
Expect(resp.StatusCode).To(Equal(200))
By("checking the CORS response")
Expect(resp.Header.Get("Access-Control-Allow-Origin")).To(Equal("*"))
By("checking the original request is included with the response")
Expect(responseData.Request).To(Equal(requestData))
By("checking the mean instances per host")
Expect(responseData.MeanInstancesPerHost).To(Equal(20.0))
By("checking the mean instances per host")
Expect(responseData.Apps).To(HaveLen(10000))
})
Describe("Web form", 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("provide a web interface to the API", func() {
By("having a root page", func() {
Expect(page.Navigate("http://" + address)).To(Succeed())
})
开发者ID:rosenhouse,项目名称:cnsim,代码行数:30,代码来源:acceptance_test.go
示例19:
package main_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/sclevine/agouti"
. "github.com/sclevine/agouti/matchers"
)
var _ = Describe("Angular", func() {
var page *agouti.Page
It("should redirect / to #/", func() {
var err error
page, err = agoutiDriver.NewPage()
Expect(err).NotTo(HaveOccurred())
Expect(page.Navigate("http://localhost:8080")).To(Succeed())
Expect(page).To(HaveURL("http://localhost:8080/#/"))
})
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())
})
开发者ID:Jackgris,项目名称:angularjsAndTestWithGo,代码行数:31,代码来源:angular_test.go
示例20:
package potato_test
import (
"time"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/sclevine/agouti"
. "github.com/sclevine/agouti/matchers"
)
var _ = Describe("UserLogin", func() {
var page *agouti.Page
salutations := "Good morning at " + time.Now().String()
BeforeEach(func() {
var err error
page, err = agoutiDriver.NewPage(agouti.Browser("firefox"))
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/"))
})
开发者ID:kinvolk,项目名称:demo,代码行数:31,代码来源:potato_test.go
注:本文中的github.com/sclevine/agouti.Page类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论