Passing the webdriver instance between groovy scripts?
<p>We've been trying to figure out how to call, (0)from a groovy script, (1)a selenium website login and then a (2) call the navigation (script) portion sitting in another test case. Running both independently works 100%. Below is the code that I use to call both the scripts from (0) but, once it's done with <code>login.run</code>, a new browser is opened with <code>select.run</code> and obviously the test fails because it's not logged in.</p>

<pre><code>login = testRunner.testCase.testSuite.project.testSuites["Selenium"].testCases["Login"].testSteps["Login_Plat"]
select = testRunner.testCase.testSuite.project.testSuites["Selenium"].testCases["Calculator"].testSteps["GS_Platinum"]

login.run(testRunner, context)
select.run(testRunner, context)
</code></pre>

<p>So I went and manipulated the <code>login</code>, <code>select</code>(by removing webdriver code)and main script code now looks like this(i've excluded the imports in this paste):</p>

<pre><code>System.setProperty("webdriver.chrome.driver",testRunner.testCase.testSuite.getPropertyValue("driverPath"))
env = testRunner.testCase.testSuite.getPropertyValue("testEnvDetails1")
WebDriver driver = new ChromeDriver()

driver.get(env)

login = testRunner.testCase.testSuite.project.testSuites["Selenium"].testCases["Login"].testSteps["Login_Plat"]
select = testRunner.testCase.testSuite.project.testSuites["Selenium"].testCases["Calculator"].testSteps["GS_Platinum"]
login.run(testRunner, context)
select.run(testRunner, context)
</code></pre>

<p>I find this in the error log of the failed login script (when I run script  0) <code>ERROR:groovy.lang.MissingPropertyException: No such property: driver for class: Script19</code> so it looks like the (1)<code>login</code> script isn't using the <code>driver</code> class from the main script(0)</p>

<p>I've looked at these similar issues too, but ours seemed to be too different from theirs.</p>

<p><a href="https://stackoverflow.com/questions/22248196/selenium-webdriver-inside-soapui-passing-the-driver-instance">selenium webdriver inside soapui, passing the driver instance</a></p>

<p><a href="https://stackoverflow.com/questions/33437415/how-to-pass-context-from-script-to-another-class-groovy">How to pass context from Script to another Class groovy</a></p>

<p><a href="https://stackoverflow.com/questions/11742995/define-a-global-class-in-soapuis-groovy-script?rq=1">How to define a global class in SoapUI as a groovy script?</a></p>

<p>and I'm trying very hard to avoid <code>.jar</code> into <code>ext</code> dir way, simply because we want to avoid at all costs(training mostly) using another program to do this. It is also a lot more efficient if we can see the code being called instead of importing it into a script as the website is being changed.</p>

<p>All three of these scripts are in the same project and test suite, but different test cases. This was done because there are going to be multiple test steps/scripts inside the login test case with different login ways and details. I'm using webdriver standalone server</p>