Groovy web console

subscribe to the feed Subscribe
to this
site

qww

Published 2 months ago by akea
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
package pages
import geb.Page

class ContactUs extends Page {
    static url = 'index.php?controller=contact'
    static at = {
        waitFor(10) {
            header.isDisplayed()
        }
    }
    static content = {
        header {
            $('div[class="center_column col-xs-12 col-sm-12"]').$('h1', text: contains("Customer service - Contact us"))
        }
    }
}




package ContactUsPage


import geb.spock.GebSpec
import groovy.util.logging.Log
import pages.ContactUs
import spock.lang.Stepwise

@Log
@Stepwise
class EnterToPageTest extends GebSpec {

    def cleanupSpec() {
        browser.close()
    }


    def "Should enter to page"() {
        given:
       to ContactUs
        expect:
        at ContactUs
    }
}





import io.github.bonigarcia.wdm.ChromeDriverManager
import org.openqa.selenium.Dimension
import org.openqa.selenium.Point
import org.openqa.selenium.chrome.ChromeDriver
import org.openqa.selenium.chrome.ChromeOptions
import org.openqa.selenium.remote.RemoteWebDriver

driver = {
    driver = { defaultSize(new ChromeDriver(chromeOptions)) }
}

reportsDir = "geb-reports"

waiting {
    timeout = 30
}

HashMap<String, Object> chromePrefs = new HashMap<String, Object>()
chromePrefs.put("profile.default_content_settings.popups", 0)
chromePrefs.put("download.default_directory", System.getProperty("user.dir") + File.separator + "firefox_downloads")
ChromeOptions chromeOptions = new ChromeOptions()
chromeOptions.addArguments("disable-infobars")
chromeOptions.addArguments("--js-flags=--expose-gc")
chromeOptions.addArguments("--enable-precise-memory-info")
chromeOptions.addArguments("--disable-popup-blocking")
chromeOptions.addArguments("--disable-default-apps")
chromeOptions.setExperimentalOption("prefs", chromePrefs)

environments {

    chrome {
        ChromeDriverManager.getInstance().version("74").setup()
        def browser = new Browser(driver: new ChromeDriver())
        driver = { defaultSize(new ChromeDriver(chromeOptions)) }
    }

}
private defaultSize(RemoteWebDriver driver) {
    driver.manage().window().setPosition(new Point(0, 0))
    driver.manage().window().setSize(new Dimension(1920, 1080))
    driver.manage().deleteAllCookies()
    return driver
}
baseUrl = System.getProperty("http://automationpractice.com")