Forum Discussion

sprice090161's avatar
sprice090161
Contributor
6 years ago

I'm running some basic Selenium from a groovy test step. Since I have a datasource feeding it, I'd l

I am executing a Groovy script containing my Selenium commands to:

  • Launch a browser
  • Login to my webapp
  • Navigate to a funtion in the app and execute 
  • Close the browser

The script is fed by an XML Datasource. So I could have 100's of iteration. I created a second Groovy script to handle the launch and login, while the second Grovvy test step performs the task.

 

Problem: The driver definition is out of scope in the second Groovy test step.

Question: Is there a was to define the browser driver object so that it can be used in multiple steps withon the test cases?

 
 

2 Replies

  • sanj's avatar
    sanj
    Super Contributor

    basically you are looking for persistance

    best approach is to have groovy script running required test steps

     

  • groovyguy's avatar
    groovyguy
    Champion Level 1

    Theres no real way to persist objects between groovy scripts. You can either build the one groovy script to have functions that contain both parts and persist that way, or re-define the browser objects in the second script.