How to reuse open Webdriver in SoapUI Groovy?

247 views
Skip to first unread message

Stefan Telley

unread,
Feb 13, 2014, 8:31:55 AM2/13/14
to seleniu...@googlegroups.com
Hi folks,

I have a problem with using Selenium in Soapui. If i load webdriver in a testCase.testStep in Soapui everything is ok. This works very good. To handle my TestCases a little bit better, I would like to split the testStep into smaller peaces. Here is my problem beginning. As soon as the testStep is finished in Soapui, all object and the webdriver connection is gone. I found out, how to get the session ID of the webdriver, but I didn't find out, how to call selenium in Groovy script, to use the same webdriver session.

Does anybody have an idea how to do that? At the moment, I get the sessionID by running this code:  def sessionId = driver.getSessionId() . Then I store this ID in a testCase Property. After that I start the next testStep. And here I have no clue how to call selenium to take the pervious webdriver session.


Thanks for your help.


Yours  Stefan

Syamasundar

unread,
Apr 23, 2014, 5:49:35 AM4/23/14
to seleniu...@googlegroups.com
Hi Stefan Telley ,
 
I am tring to automate the soapui for webservice testing. Can you please share the sample code how to automate it.
Your help would be appricited and thanks in advance.


--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/06bd06fa-52aa-4fe0-a084-a05a4bf334de%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

erki manniste

unread,
Apr 23, 2014, 8:26:44 PM4/23/14
to seleniu...@googlegroups.com

Using webdriver from soapUI groovy script is possible, i did it some time ago, also, you can work around the spaghetti code by setting your classes as context objects in groovy and then call it from another groovy script. Anyway, using soapUI as you test harness may seem like a neat idea in the beginning, but soon enough you will end up writing everything in java (at least i did) and at that point you ask yourself: "what benefits do I get comparing to pure java test code together with testng or similar" and, (oh did i think of it), you'll probably end up with none. So if you need to do something that some managers call end-2-end testing, meaning you will trigger some action from webUI, that will trigger an call to a webservice, that will trigger a call to a database, that will trigger a response to a webservice that will return some stuff to UI ... and you want to test all 42 paths of that algorithms in one test (you shouldnt but people can ask for it).. then it is possible, that you will end up in a situation where 9 out of 10 of your soapUI teststeps are of type groovy script, and all you get is that you lose the flexibility you get when you just write your testcode in pure java.
Anyway, sry, a lot of text, a little information. What you want is (from top of my head):

class Login{
    def context;
    def testRunner;
    def log;
    WebDriver driver;
    @FindBy(id = "userBlablA") WebElement userName;
    @FindBy(id = "passPass") WebElement password;
    def Login(logIn, contextIn, testRunnerIn){
           // trololooo, so logged in soon ! !1
    }

        public void login(){
              userName.sendKeys("boss");
              password.sendKeys("hasReturned");
              // do more stuff
    }
}

And, after the class, you will just set it as a context propery so you can call it if you want, something like:
context.setProperty( "login", new Login(log, context, testRunner) )

-----
and then, should you need it, in another groovy script you can just tell something like:

    testRunner.testCase.testSuite.project.testSuites["mega"].testCases["yolo"].testSteps["logg"].run(testRunner, context)
     // do register
    def inLogger = context.login
    inLogger.login()

So that is basically it.


good luck
erki
Reply all
Reply to author
Forward
0 new messages