package specs import geb.spock.GebReportingSpec class GebDemoSpec extends GebReportingSpec { def "Testing Basic Page Contents"(){ setup: go "http://localhost:9000/#/demo/geb-demo" expect: //Asserting Basic CSS Selector $("h2").text() == "Rock and Roll Hall of Fame" //Using Index $("h3", 0).text() == "Better than the Best" $("h3", 1).text() == "Subscribe Newsletter" //Finding and Filtering Descendants $("div.col-md-4", 0).find("strong").text() == "Top Songs List" $("div.panel-heading").has("strong").size() == 3; } def "Testing Form Interaction with Valid Email and CheckBox Checked"(){ setup: go "http://localhost:9000/#/demo/geb-demo" when: "User Enters Valid Email" $("#exampleInputEmail").value("hellouser@gmail.com"); $("input", type: 'checkbox', name: "termsAndConditions").value(true) and: "Clicks Submit Button" $("button", type: "submit").click(); then: "Redirects to Digi Marketplace Main Homepage" $("h2").text() == "Digi Marketplace"; } def "Testing Form Interaction with InValid Email"(){ setup: go "http://localhost:9000/#/demo/geb-demo" when: "User Enters Valid Email" $("#exampleInputEmail").value("hellouser.com"); and: "Clicks Submit Button" $("button", type: "submit").click(); then: "Should Remain in Same Page" $("h2").text() == "Rock and Roll Hall of Fame"; } }