Hi all,
I'm trying to create some DSL for my application. And here is what I have done till now; The groovy script below calls the DSL after setting up the base script class etc. def handler = new SeleniumCallHandler() def binding = new Binding(driver: handler.getDriver(),seleniumcallhandler: handler) def importCustomizer = new ImportCustomizer(); importCustomizer.addImport("By","org.openqa.selenium.By") def config = new CompilerConfiguration(); config.addCompilationCustomizers importCustomizer config.scriptBaseClass = SeleniumBaseScript.name //driver.findElement(By.id("lst-ib")).sendKeys("Selenium!") def shell = new GroovyShell(this.class.classLoader,binding,config) shell.evaluate(new File("loadGroovyPage.groovy")) and SeleniumBaseScript: abstract class SeleniumBaseScript extends Script { @Delegate @Lazy SeleniumCallHandler seleniumcallhandler = this.binding.seleniumcallhandler } loadGroovyPage.groovy: TestBehavior('test google home page' , { loAd "http://www.google.com" driver.findElement(By.id("lst-ib")).sendKeys("Selenium!") }) the TestBehavior method is defined in SeleniumCallHandler. Like: def TestBehavior(def name,Closure cls) { cls.delegate = this; cls(); } The above code in loadGroovypage works fine. But to make my DSL good, I tried this: TestBehavior 'test google home page' , { loAd "http://www.google.com" driver.findElement(By.id("lst-ib")).sendKeys("Selenium!") } (same code without param's) And this code fails with message: Error:(1, 13) Groovyc: unexpected token: test google home page on loadGroovyPage.groovy. Where I'm making the mistake? Does the method call without params should work without any issues right? Thanks, Anto.