androidautomated-testsappiumspockgeb

How to achieve page object mechanism with Geb Spock Appium


I am effectively using geb-spock for our web application. I am new to geb spock appium and struggling with PageObject mechanism in Appium as I have comfortably achieved that for web application.

I am successfully able to launch the App and able to perform some actions on app with below code.

@Stepwise
class TC_001_DictionaryApp_Spec extends GebReportingSpec {

    def "Step 1:Go to the login page of the WU"() {
        when: "User is on Dictionary App"
        // at AppHomePage

        and: " User enters the value in Searh box"
        /*page.textboxSearch.value("Obsess")*/
        driver.findElement(By.id("com.dictionary.mr:id/input_text_view")).sendKeys("Obsess")

        and: "Press the Enter"

        then: "Word should be searched"
    }
}

However if I try to use at or to block then its getting failed. (If you un-comment the code in the above test case it's not working) Below is my page object class

class AppHomePage extends Page {
    static at = {}

    static content ={
        textboxSearch (wait:true) { driver.findElement(By.id("com.dictionary.mr:id/input_text_view")) }
    }
}

Can you please guide me how I can achieve the page object mechanism with geb spock appium.

Thanks!


Solution

  • You haven't added an assertion in your "at" block so it will fail.

    class AppHomePage extends Page {
    
        static at = { title == "my title assertion"}
    
        static content ={
            textboxSearch (wait:true) { driver.findElement(By.id("com.dictionary.mr:id/input_text_view")) }
        }
    }