Redirection to an specific url after logging in

327 views
Skip to first unread message

Bocar Alpha Ba

unread,
Sep 22, 2015, 5:51:35 AM9/22/15
to Geb User Mailing List

 I want to access to my page http:localhost:8080/ppf/fact/mmapay after logging in and displayed the index page.

I use given -via -expect - at , But it seems doesn't redirect me to the correct page..

Please help me to do that


Below the test code

import geb.spock.GebReportingSpec
import pages.*
import spock.lang.Stepwise

@Stepwise
class FactControllerSpec extends GebReportingSpec {

def "redirecton vers la methode fact"() {
        given:
        via TableauBordPage
        expect: 
        at FactPage
    }
}


Below the GEBCONFIG

environments {

    chrome { driver = { new ChromeDriver() } }
    System.setProperty("webdriver.firefox.bin", "C:/Program Files (x86)/Mozilla Firefox/firefox.exe")
    driver = {
        FirefoxProfile profile = new FirefoxProfile()
        profile.setPreference("intl.accept_languages", "en-us")
        def driverInstance = new FirefoxDriver(profile)
        driverInstance.manage().window().maximize()
        driverInstance
    }
    baseUrl = "http://localhost:8080/ppf/"
}


And the  desciption page who to redirect

package pages

import geb.Page

class FactPage extends Page {

    static url = "fact/mmapay"

    static at = { title == "[Paynum] Paiement en ligne de votre facture" }

    static content = {
        codeFactureField { $("input", name: "code") }
        nomField { $("input", name: "nom") }
        prenomField { $("input", name: "prenom") }
        rechercheCodeFactureButton { $("button", type: "submit") }
        aurevoirButton1 { $("a", text: "Abandonner") }
        rechercheFactureButton { $("button", type: "submit") }
        aurevoirButton2 { $("a", text: "Abandonner") }
    }
}

Bocar Alpha Ba

unread,
Sep 22, 2015, 8:07:00 AM9/22/15
to Geb User Mailing List
Finally i changed my test code and it works

def "redirecton vers la methode fact"() {
when:
go "localhost:8080/ppf/fact/mmapay"
then:
title == "[Paynum] Paiement en ligne de votre facture"
at FactPage

Marcin Erdmann

unread,
Sep 22, 2015, 8:35:57 AM9/22/15
to geb-...@googlegroups.com
Be aware that your code from the second email has the exact same effect as the following:

def "redirecton vers la methode fact"() {
  expect:
  to FactPage
}

What I mean is that all that code you have there is redundant because to() performs an implicit at check and the condition on title you have there is exactly the same as contents of the at checker for FactPage.

--
You received this message because you are subscribed to the Google Groups "Geb User Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to geb-user+u...@googlegroups.com.
To post to this group, send email to geb-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/geb-user/6d6f9c66-6d4a-4ee5-84cb-3da8fbc0cd89%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages