Hi,

      I am reading the book 'Groovy in Action' and this code is based on
that.

My base script stores 'DynamicXPath' like this.

abstract class AxesBaseScript extends Script {

    public DynamicXPath bootStrap(String initialPath ){
        this.binding.dxp.bootStrap initialPath
    }
}

And here I want to execute a dynamic DSL command 'dsl '

by storing it in the binding as 'DslCommand'.

    def evaluatexpath( String dsl ){
        def binding = new Binding(
                dsp: new DynamicXPath(),
                DslCommand: dsl
        )

        def shell = new GroovyShell(this.class.classLoader, binding)

        shell.evaluate '''
            @BaseScript(com.automation.script.AxesBaseScript)
            import groovy.transform.BaseScript
            DslCommand
        '''
    }

Looks like the DSL string I pass 'bootStrap somestring' is returned as it
is as a string by evaluate.

Can I not execute 'bootStrap somestring' ?

The relevant section in the book is '*Listing 19.12 Using a custom base
script class'*

*My '*DslCommand' replaces 'move left' which you see at the end of the
listing.
I just want to pass my DSL commands to the evaluate method as parameters
through the binding.


Thanks,
Mohan

Reply via email to