webcrew
webcrew

Reputation: 157

changing / selecting a value in a dropdown box .. using Geb

As a Geb Newb, this is confusing. In attempting to click on a combo/dropdown box, I'm getting the following error:

"geb.error.RequiredPageContentNotPresent: The required page content 'pages.ecomm.NewEnrollmentPage -> countrySelected: geb.module.Select' is not present"

1. page looks like this enter image description here

2. here is my source:

3. test spec code, for selecting dropdown. Error appears to indicate the 'countrySelected' content/element isn't on the page? Or I'm not even on the page?

NewEnrollmentPage.groovy

import geb.Page
import geb.module.Select

class NewEnrollmentPage extends Page {


    static url = "/shop/spring/enrollment/start/78867?tagCountry=AN&customerType=D&tagLang=ENU&__checkbox_isPC=true&UNI_TODAY=true&__checkbox_UNI_TODAY=true&clearSession=1"
                // "/shop/spring/enrollment/product/landing"
                // below for mwebs (non-prod) --->v

    //At Checker
    static at  = {
        title == "Enrollment"
    }

    static content = {
        // <navigatorName ><options map> <actual navigator>
        CrInitOrdButton(wait: true) { driver.findElement(By.id($("[id='toProductsPage']"))) }
        countrySelected { $("#countrySelected").module(Select) }
        //Options Map
        /* wait : true
         * required : false
         *
         *
         *
         */
    }
}

test.groovy

class test extends smoke.ecomm.resource.ShopBootStrap {

   def "Select Country"() {
        given:
            at NewEnrollmentPage
        when: "select United States for Country"
            **countrySelected.value('US')**

    .
    .
    .

    }

}

Upvotes: 0

Views: 828

Answers (1)

erdi
erdi

Reputation: 6954

Your selector is incorrect. You are selecting using id of countrySelected but that's the name of your element and its id is actually countries. So you need to change your content definition to either:

countrySelected { $("#countries").module(Select) }

or

countrySelected { $(name: "countrySelected").module(Select) }

Upvotes: 2

Related Questions