I mean that this works if the DSL command is hard-coded. I was trying to
pass it into the shell.
Am I allowed to pass it into the shell ? This evaluation is generic for
many such fluent commands.
def evaluatexpath( String dsl ){
def binding = new Binding(
dxp: new DynamicXPath(),
DslCommand: dsl
)
def shell = new GroovyShell(this.class.classLoader, binding)
shell.evaluate '''
@BaseScript(com.automation.script.AxesBaseScript)
import groovy.transform.BaseScript
bootStrap "//*[@id='pane']"
'''
}
Mohan
On 16 January 2018 at 19:06, Mohan Radhakrishnan <
[email protected]> wrote:
> 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
>