I strongly believe complete newbies like me find it very difficult to understand why are we starting with groovy in the first place. so far i had understood loading the WSDls, end point URLs, sending the request, getting a valid response, creating a test suite>test case>test step. From a practical standpoint it would be helpful for me to know why do i need to learn groovy after this. In my project on webservice testing i didnt need it. So if you could start with a basic intro as to why do we need groovy here will be helpful
Hi Yatishankar, I got your point. A session on why its needed, where it will help etc will help. Although some of this is mentioned during the sesion, but I can understand for newbies, a separate session will help. Will try to add this
Hi Raghav, You are an awesome teacher. As a student, the only thing that makes us more clear is if you give a meaningful name to a particular test case or test suit or for any method you are using will help us to understand in the best way. I am getting too much confused on name like test suit 1, test case 2, and so on. sorry about that. Else Everything is perfect.
Hi Raghav, your videos are really educational and useful. They are of great help to me to better understand groovy in automation tests. greetings from Spain.
Your videos are very helpful and well organized. I like the use of notepad! When you get to the crux of a helpful point perhaps slow down a tad so that I needn't pause the video (if you're still making these years later). Thanks!
Hi Pragati, What exactly is your scenario, In case you want to run in a loop you can do that using groovy script. e.g. // This will get the list of all testSteps in the testCase def testSteps = context.testCase.getTestStepList() testSteps.each{ // This block will loop through the test steps and print the test step name to the log log.info(it.name) }
context Analogy...if i understand it correctly ... once we create a class and its methods, then we call it from different class. But, here we need to define variable to the class -def testStep = testRunner.testCase.getTestStepByName("Hello"); .this is something like deciding which which fun activity to go in the amusement park. Once we decide, we need a different passes/tickets to play the different rides. these pass/tickets are "Context" testStep.run(testRunner, context); . Once we get the pass we get access to that ride/area in amusement park. Once we do enter there we can play the ride which is actual function calling activity. context.Hello.sayHello() Lol..just trying to figure it out.confirm if this right and easy way to understand context..because context object is used in different languages as well for example dart in flutter.
Hi Raghav, Very well explained. Can you please provide syntax too? Example: to call a class that is defined in another test case. tcase=project.teststeps("").testcases("");
Hi Raghav, firstly i thank you for your tutorial serie, very helpful also because regarding SoaupUi, there aren't much guides out of here nowdays. So, i want to ask you one ore more practical use cases to implement a object-oriented program in a api test. I've seen this when implementing Selenium with customs libraries in e2e testing, but i can't immagine a usefull case in api testing.
While object-oriented programming (OOP) isn't as prevalent in API testing as it is in UI testing, there are certainly practical use cases where it can bring significant benefits: 1. Modeling Complex Data Structures: * API responses or requests often involve nested objects and arrays. Object-oriented data structures like classes and interfaces can effectively represent these complexities, making tests more readable and maintainable. * Create dedicated classes for "user", "order", "product", etc., with properties and methods reflecting their real-world counterparts. 2. Reusability and Modularity: * Break down common test logic into reusable methods within classes. This promotes code reuse and reduces duplication across tests. * Implement "base classes" for common API interactions (authentication, authorization), and inherit them for specific tests, reducing boilerplate code. 3. Encapsulation and Abstraction: * Encapsulate complex logic within methods or properties, hiding implementation details and improving test readability. * Use interfaces to define expected behaviors without specifying concrete implementations, promoting flexibility and future changes. 4. Data-Driven Testing: * Create classes to encapsulate different test data sets, making data-driven testing more organized and scalable. * Use inheritance or composition to create variations of test data based on specific scenarios. 5. Mocking and Stubbing: * Develop custom mock objects mimicking external dependencies (third-party APIs, databases) using OOP principles. * This allows isolation and control of these dependencies in your tests. Examples: * Product API testing: Create a `Product` class with properties like ID, name, price, and methods for CRUD operations. Write tests that interact with the API using this class for clarity and reuse. * Authentication testing: Build an `Authentication` class with methods for login, logout, and token management. Leverage inheritance for specific authentication flows (OAuth, Basic Auth). Remember, OOP isn't always necessary, but when dealing with complex APIs or aiming for maintainable and scalable tests, it can provide significant advantages. Don't hesitate to adopt it when it enhances your testing practices.
Raghav very thank you for all these tutorials and that you give us for free! You are the best! I also have a youtube channel where I explain different things. You are my role model. I'd like to have a question, I have written a groovy script where I read data from excel and I'd like to do that my only test case loops through the rows that are in excel. So one row in excel stores all the data for one test case and each line means a different test case, but the test case form (all the request, etc) are the same. Or in other words, I have only one test case which contains all the necessary things. It has a groovy script which reads the rows from excel and every row means a complete run of the test case. p.s. I have a soapUI project where I have setup scripts which contain a class but it doesnt contain these variables that you say the class should contain. Another question which I'd like to have at the end of the video, what is the reason of these method invocations order: project = testRunner.testCase.testSuite.project ?
Hi István, so glad to know this. You might have to do some custom coding for making every line a test case in excel. these are the classes and interface in soapui library. You can read api docs to get more info
Hello Raghav always love your videos great explanation...can you please tell me how do we make JDBC connection and do database verification in groovy...it would be really helpful... thank you
Thank you Raghav, that was very useful. I've connected to the DB successfully through JDBC request and successfully retrieve the records using SQl queries.. How can I compare the response values against the DB returned values using Groovy script? Can you advise please?
@@RaghavPal. Sure Raghav. Sorry, I missed the notification as previously commented from my husband's mobile. I've used context.expand to refer to the soap response and the JDBC request- response. Here is the example code: def soapDataItem = context.expand ('$ { teststepnameofSOAPRequest#Response#//xpathoftheproperty}') def JDBC DataItem = context.expand ('$ { teststepnameofJDBCRequest#ResponseAsXml#//xpathoftheproperty}') assert soapDataItem == JDBCDataItem
Hi Raghav, your teaching is amazing and very easy to follow and did a hands on too and it was very productive. But in this video I was unable to follow much of it, I lost it at the very beginning itself maybe due to as I have zero programming knowledge. So, can you guide and assist me how to overcome this gap. Thanks again!
Thanks again for your great course. Is it possible to run a Selenium script using a Groovy step in a SoapUI test case? Do you go into that later in your video series? At work we have a step that needs to be carried out from a screen interface because there is no WSDL for it. Also, I have a specific question about something I want to do on a project for my job. Would you consider doing a one-to-one session with me? I don't think it would take very long.
Hi Angel, you can see this one - czcams.com/video/GSAt7YOvjbY/video.html&list=PLhW3qG5bs-L-Bt9T_bnyflQ0Te4VgFhKF Playlist - czcams.com/play/PLhW3qG5bs-L-Bt9T_bnyflQ0Te4VgFhKF.html
Hello Sir, Thankyou for such great informational videos . Always follow your videos. Also please can you once upload a token handling video for Jmeter. Actually i am trying to handle dynamic tokens in Jmeter and not getting the exact results with regular expressions. I will be very thankful in case you can help me out that Groovy scripting in J meter as well.
Hi Ragav, Excellent presentation. Very easy to understand. Thank you! Have a doubt, which tool will be the best for Web Service Load or Performance Testing (Load UI/LoadRunner/Jmeter..etc). Thanks!
Hi Nirmal, it depends on the need, features, budget etc. JMeter is free and lots of online support is available. However if you need to do geographical distribution, you will need multiple systems or go with some paid services like Blazemeter. Paid tools like LoadRunner have many out of the box features. So it depends.
Hi Raghav, @9:45 , the list of printed methods from testRunner class is not having the testCase method. This testCase is very commonly used method right, why is its not available in the list of methods got printed?. Below are the methods names printed [cancel, equals, fail, getClass, getLog, getReason, getResults, getRunContext, getStartTime, getStatus, getTestCase, getTestRunnable, getTimeTaken, gotoStep, gotoStepByName, hashCode, isRunning, notify, notifyAll, runTestStep, runTestStepByName, setMockRunContext, setRunContext, start, toString, wait, waitUntilFinished] Please clarify this doubt.
Hello Raghav, I have written this code to execute the case, but getting null pointer exception error at statement number 4. project = testRunner.testCase.testSuite.project ; tcase = project.testSuites["TestSuite3"].testCases["TestCase2"] ; tstep = tcase.getTestStepByName("GetCountryISOCode"); def status = tstep.run(testRunner, context) def result = status.getStatus().toString(); log.info (" >>>> "+result)
Sir for me the last demo didn't work the error is " Mon Dec 25 16:11:10 IST 2023:ERROR:An error occurred [Cannot get property 'testCase' on null object], see error log for details "
Abhishek Here are the steps to address it: 1. Analyze Error Details: Review Error Log: Inspect SoapUI's error log for specific line numbers and clues about the script's context. Check Console Output: Look for additional error messages or stack traces that might provide more insights. 2. Identify Null Object: Examine Variable Usage: Carefully review your script to determine where the testCase property is being accessed. Verify Context: Ensure that the script is executing within a valid test case context where the testCase property should be accessible. 3. Common Causes and Solutions: Incorrect Script Placement: If the script is not within a test case or test step, it won't have access to the testCase property. Move the script to the appropriate location within a test case or test step. Missing Test Case Reference: If the script is in a separate file or custom library, ensure it's properly referencing the test case object. Pass the test case object as a parameter to the script or use appropriate methods to access it. Script Execution Order: If the script depends on other test steps or variables, verify that they are executing in the correct order. Adjust the test case structure or use conditional logic to ensure proper execution flow. Global Properties: If you're using global properties, double-check their names and values to ensure they are defined correctly. 4. Debugging Tips: Use Logging: Add log.info statements to print variable values and track script execution flow. Isolate the Issue: Comment out parts of the script to narrow down the problematic code. Test Incrementally: Build and test your script in small, manageable sections. 5. Additional Considerations: SoapUI Version: If you're using an older SoapUI version, consider upgrading to avoid compatibility issues. Script Complexity: For complex scripts, consider using techniques like modularization and error handling to improve readability and maintainability.
Great tutorial, so seems to me that use of classes is more like static right? or by doing this testinit = tcase.getTestStepByName("anyclass"); you are creating an object of that type? Thanks!
So here a lot of inbuilt functions are provided by soapui. like getTestStepByName() is a function already available in an existing class and we can call it to get the value
Hi sir, i have a doubts 1. If we mentioned path parameter wrong in the uri what status code we get and we mentioned wrong Query parameter what status we get, we get 404 only for both path and query parameters or we get different status code. 2. what is the main difference between Bearer token and Token generated through API
Here are the answers to your SoapUI API testing questions: 1. Status Codes for Incorrect Parameters: - Incorrect Path Parameter: - Most likely results in a 404 Not Found status code, indicating the requested resource doesn't exist at the specified path. - Incorrect Query Parameter: - Varies depending on API implementation: - Might return a 400 Bad Request status code if the parameter is invalid or essential for processing. - Could return a 404 Not Found if the parameter is crucial for resource identification. - Might ignore invalid parameters and return a 200 OK status code with potentially unexpected results. Key takeaways: - API documentation should specify expected status codes for different error scenarios. - Testing with both correct and incorrect parameters is crucial for robust API testing. 2. Differences Between Bearer Token and API-Generated Token: - Bearer Token: - Self-contained access token representing authorization to access protected resources. - Typically obtained through OAuth 2.0 or OpenID Connect flows. - Used by adding "Bearer" keyword before the token in the Authorization header. - Example: `Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...` - API-Generated Token: - Created by the API itself upon successful authentication or other actions. - Specific usage varies depending on API design: - Can be used for authorization, session management, or other purposes. - Might be included in request headers, query parameters, or body data. - Example: `Authorization: Token 1234567890abcdef` Key takeaways: - Bearer tokens are a standardized way to handle authorization in web APIs. - API-generated tokens offer flexibility for custom authentication and authorization mechanisms. - API documentation should clarify the types of tokens used and their intended usage. Additional considerations for SoapUI: - Use test steps to set appropriate headers for different token types. - Assert expected status codes to verify API behavior in response to incorrect parameters. - Leverage SoapUI's test suites and reporting features for comprehensive API testing.
Hi Raghav, I have one query.In the 'CallHello' test step , why did you write testStep.run(testRunner,Context) ? I could not understand the need for that line of code. Thanks, Minu
Hi Minu, log, context and testRunner are global variables and is present everytime in SoapUI. Now I may not go very deep but you can directly use them in your scripts as and when required and there are some in built syntaxes like the one above. You may check more in the documentation
As part of groovy scripting I'm unable to call 2 values from excel to do addition soap request . Please help. Its throwing error stating "org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script4.groovy: 3: unable to resolve class".
@Automation Step by Step project =testRunner.testCase.testSuite.project; tcase = project.testSuites("TestSuite3").testCases("TestCaseName1"); hello = tcase.getTestStepByName("Hello"); hello.run(testRunner, context) context.Hello.sayHello("Vipin") For this Program i didn't got the proper output ; groovy.lang.MissingMethodException: No signature of method: com.eviware.soapui.impl.wsdl.WsdlProject.testSuites() is applicable for argument types: (java.lang.String) values: [TestSuite3] Possible solutions: getTestSuites() error at line: 2
@@RaghavPal Is there any difference happens, if 1) Right click on Test steps>Add Step>Groovy Script 2) Right click on Test case1, in Test suite 3 as in Vedio>Addstep>Groovy Script I have done both one for class Hello and one for Calling the method, since the structure of Test suite remained same I didn't bother.
how to write this in a single line? project = testRunner.testCase.testSuite.project ; tcase = project.testSuites["TestSuite3"].testCases["TestCase1"] ; hello = tcase.getTestStepByName("Hello");
Hi Anitha, I believe I replied to a similar question earlier. Just try to combine these like hello = testRunner.testCase.testSuite.project.testSuites["TestSuite3"].testCases["TestCase1"].getTestStepByName("Hello")
Hi Raghav, I need help with the blow can you help? Test Step Name: Read Data from Excel file Script Groovy Script Web Services Method N/A Activity 1. Read the inputs from a input.xls (define in project level property datafile) and set the values o the test case level properties x and Y 2. Run the Addition Test from groovy script 3. Fetch the result value from the response and set the fetched result value as the value to the test case level property z 4. Write the result value into the console log
@@RaghavPal Thankyou Raghav Please let me know if I register for your CZcams Course will you be able to speak over chat and get help in solving codes like this , I want to learn this in details
Hi Krishna, you will have to get the response and then use JsonSlurper. You will get some groovy videos in this playlist - czcams.com/play/PLhW3qG5bs-L-Bt9T_bnyflQ0Te4VgFhKF.html Can take some online help as well
Hi Ragav project =testRunner.testCase.testSuite.project; tcase = project.testSuites("TestSuite3").testCases("TestCaseName1"); hello = tcase.getTestStepByName("Hello"); hello.run(testRunner, context) context.Hello.sayHello("Vipin") Output : got this below error please help . groovy.lang.MissingMethodException: No signature of method: com.eviware.soapui.impl.wsdl.WsdlProject.testSuites() is applicable for argument types: (java.lang.String) values: [TestSuite3] Possible solutions: getTestSuites() error at line: 2
Hi Vipin, the syntax is wrong. it should be tcase = project.testSuites["TestSuite3"].testCases["TestCaseName1"] ; it is square brackets and not circular brackets
I wanted to give multi data to single xml And wanted to take the xml automatically from any datasoruce...using soapui free version... Thanks in advance
Hi Steffy, I will plan to create a tutorial on that. You can try getting some online help meanwhile. Check this stackoverflow.com/questions/46407278/how-to-get-data-from-excel-to-soapui-request community.smartbear.com/t5/SoapUI-Pro/Get-xls-data-in-loop-in-groovy-script/td-p/27864
@@RaghavPal context.setProperty("Hello", new Hello(log,context,testRunner)) - does this statement will add a custom property with the name Hello and value of the constructor to the groovy test step Hello? Because I checked my system and I did not find the custom property Hello under the groovy test step...
Online courses - automationstepbystep.com/
We have implemented this groovy explained in the video, its a big success for the project. Thank you!
So happy to know this Ullasa
I strongly believe complete newbies like me find it very difficult to understand why are we starting with groovy in the first place. so far i had understood loading the WSDls, end point URLs, sending the request, getting a valid response, creating a test suite>test case>test step. From a practical standpoint it would be helpful for me to know why do i need to learn groovy after this. In my project on webservice testing i didnt need it. So if you could start with a basic intro as to why do we need groovy here will be helpful
Hi Yatishankar, I got your point. A session on why its needed, where it will help etc will help. Although some of this is mentioned during the sesion, but I can understand for newbies, a separate session will help. Will try to add this
@@RaghavPal Thank you for your lucid explanations .. please help to find the separate session which you have mentioned above .
You taught me how to run any testCase, which is awesome and just what we needed to reduce regression tests in soapUI. Many thanks and Kudo's!
Most welcome
Hi Raghav, You are an awesome teacher. As a student, the only thing that makes us more clear is if you give a meaningful name to a particular test case or test suit or for any method you are using will help us to understand in the best way. I am getting too much confused on name like test suit 1, test case 2, and so on. sorry about that. Else Everything is perfect.
Hi Prabhat, I completely got your point Prabhat and will take care of this in future tutorials
Hi Raghav, your videos are really educational and useful. They are of great help to me to better understand groovy in automation tests. greetings from Spain.
Glad to hear that Emilio
Hi Raghav your presentation is very helpfull thank you somuch.
You're welcome Md. Amin
Your videos are very helpful and well organized. I like the use of notepad! When you get to the crux of a helpful point perhaps slow down a tad so that I needn't pause the video (if you're still making these years later). Thanks!
Awesome, thank you!
Thank You Raghav , It is very useful and very understanding .
Most welcome Rajani
hi thank you for giving this valueable infirmation great sir there no one canot expail like this clearly about groovy
You're welcome Nagaswa:)
Raghav pal sir your my best teacher
Great to know this Gowri. I am humbled.
Very helpful to get started using groovy
Great to know this Pavithra
Good explanation sir of every topic...keep it up
Thanks and welcome Sana
Nicely explained about groovy scripting thanks a lot!!!
Most welcome Mayank
Thanks for the wonderful video. Please let me know how to run more than on e test steps or test cases using single statement
Hi Pragati, What exactly is your scenario, In case you want to run in a loop you can do that using groovy script. e.g.
// This will get the list of all testSteps in the testCase
def testSteps = context.testCase.getTestStepList()
testSteps.each{
// This block will loop through the test steps and print the test step name to the log
log.info(it.name)
}
@@RaghavPal thanks this is all I wanted.
Thank you so much for helping me in all the project requirements I am in
You're welcome Lakshmi
context Analogy...if i understand it correctly ... once we create a class and its methods, then we call it from different class. But, here we need to define variable to the class -def testStep = testRunner.testCase.getTestStepByName("Hello"); .this is something like deciding which which fun activity to go in the amusement park. Once we decide, we need a different passes/tickets to play the different rides. these pass/tickets are "Context" testStep.run(testRunner, context); . Once we get the pass we get access to that ride/area in amusement park. Once we do enter there we can play the ride which is actual function calling activity. context.Hello.sayHello()
Lol..just trying to figure it out.confirm if this right and easy way to understand context..because context object is used in different languages as well for example dart in flutter.
yes, can go with it
Hi Raghav,
Very well explained. Can you please provide syntax too? Example: to call a class that is defined in another test case. tcase=project.teststeps("").testcases("");
I will cover this, Not sure if I have done this in any later videos, I have some more Groovy sessions in SoapUI in my Udemy course
@@RaghavPal
Do you have concepts that are not covered here in Udemy course?
A major part is the same, There are few Groovy Scripting sections. You can check all sections and lecture in the course Curriculum
@@RaghavPal Thank You
Hi Raghav, firstly i thank you for your tutorial serie, very helpful also because regarding SoaupUi, there aren't much guides out of here nowdays.
So, i want to ask you one ore more practical use cases to implement a object-oriented program in a api test. I've seen this when implementing Selenium with customs libraries in e2e testing, but i can't immagine a usefull case in api testing.
While object-oriented programming (OOP) isn't as prevalent in API testing as it is in UI testing, there are certainly practical use cases where it can bring significant benefits:
1. Modeling Complex Data Structures:
* API responses or requests often involve nested objects and arrays. Object-oriented data structures like classes and interfaces can effectively represent these complexities, making tests more readable and maintainable.
* Create dedicated classes for "user", "order", "product", etc., with properties and methods reflecting their real-world counterparts.
2. Reusability and Modularity:
* Break down common test logic into reusable methods within classes. This promotes code reuse and reduces duplication across tests.
* Implement "base classes" for common API interactions (authentication, authorization), and inherit them for specific tests, reducing boilerplate code.
3. Encapsulation and Abstraction:
* Encapsulate complex logic within methods or properties, hiding implementation details and improving test readability.
* Use interfaces to define expected behaviors without specifying concrete implementations, promoting flexibility and future changes.
4. Data-Driven Testing:
* Create classes to encapsulate different test data sets, making data-driven testing more organized and scalable.
* Use inheritance or composition to create variations of test data based on specific scenarios.
5. Mocking and Stubbing:
* Develop custom mock objects mimicking external dependencies (third-party APIs, databases) using OOP principles.
* This allows isolation and control of these dependencies in your tests.
Examples:
* Product API testing: Create a `Product` class with properties like ID, name, price, and methods for CRUD operations. Write tests that interact with the API using this class for clarity and reuse.
* Authentication testing: Build an `Authentication` class with methods for login, logout, and token management. Leverage inheritance for specific authentication flows (OAuth, Basic Auth).
Remember, OOP isn't always necessary, but when dealing with complex APIs or aiming for maintainable and scalable tests, it can provide significant advantages. Don't hesitate to adopt it when it enhances your testing practices.
Thanks for the video
You're welcome Ramzi
Raghav very thank you for all these tutorials and that you give us for free! You are the best! I also have a youtube channel where I explain different things. You are my role model. I'd like to have a question, I have written a groovy script where I read data from excel and I'd like to do that my only test case loops through the rows that are in excel. So one row in excel stores all the data for one test case and each line means a different test case, but the test case form (all the request, etc) are the same.
Or in other words, I have only one test case which contains all the necessary things. It has a groovy script which reads the rows from excel and every row means a complete run of the test case.
p.s. I have a soapUI project where I have setup scripts which contain a class but it doesnt contain these variables that you say the class should contain.
Another question which I'd like to have at the end of the video, what is the reason of these method invocations order: project = testRunner.testCase.testSuite.project ?
Hi István, so glad to know this.
You might have to do some custom coding for making every line a test case in excel.
these are the classes and interface in soapui library. You can read api docs to get more info
I like the way you explain things
thanks
You're welcome Aftab
Hello Raghav always love your videos great explanation...can you please tell me how do we make JDBC connection and do database verification in groovy...it would be really helpful... thank you
Hi Arjun, I will try to do a video, but can take some time. Pls get some online help meanwhile
Thank you Raghav, that was very useful. I've connected to the DB successfully through JDBC request and successfully retrieve the records using SQl queries.. How can I compare the response values against the DB returned values using Groovy script? Can you advise please?
Hi Nagendran, I will plan to have a session on this. For now check - testingneeds.wordpress.com/2016/11/21/soapui-push-and-pull-data-from-database/
@@RaghavPal Thanks very much Raghav. Managed to pull the Db response. looking forward to your session.
Great Nagendran, it will help others if you can put your solution here
@@RaghavPal. Sure Raghav. Sorry, I missed the notification as previously commented from my husband's mobile. I've used context.expand to refer to the soap response and the JDBC request- response. Here is the example code:
def soapDataItem = context.expand ('$ { teststepnameofSOAPRequest#Response#//xpathoftheproperty}')
def JDBC DataItem = context.expand ('$ { teststepnameofJDBCRequest#ResponseAsXml#//xpathoftheproperty}')
assert soapDataItem == JDBCDataItem
what is the purpose to write run method? Why we have pass those 2 arguments and from where they will get value?
Hi, its inbuilt in SoapUI, you can see the documentation for more details
Hi Raghav, your teaching is amazing and very easy to follow and did a hands on too and it was very productive. But in this video I was unable to follow much of it, I lost it at the very beginning itself maybe due to as I have zero programming knowledge. So, can you guide and assist me how to overcome this gap. Thanks again!
Hi Ashish, can learn Groovy from my tutorials here - automationstepbystep.com/
@@RaghavPal Thanks a lot! Raghav for the much valuable and helpful assistance.
Thanks again for your great course.
Is it possible to run a Selenium script using a Groovy step in a SoapUI test case? Do you go into that later in your video series? At work we have a step that needs to be carried out from a screen interface because there is no WSDL for it.
Also, I have a specific question about something I want to do on a project for my job. Would you consider doing a one-to-one session with me? I don't think it would take very long.
Hi Phil, You can do that, although not covered here. You can add selenium jars and then use groovy script or can also call a java jar for this.
Hello Raghav, do you have video where you show how to put the result of a wsdl in variable, so that in another wsdl that result can be used?
Hi Angel, you can see this one - czcams.com/video/GSAt7YOvjbY/video.html&list=PLhW3qG5bs-L-Bt9T_bnyflQ0Te4VgFhKF
Playlist - czcams.com/play/PLhW3qG5bs-L-Bt9T_bnyflQ0Te4VgFhKF.html
Hello Sir, Thankyou for such great informational videos . Always follow your videos. Also please can you once upload a token handling video for Jmeter. Actually i am trying to handle dynamic tokens in Jmeter and not getting the exact results with regular expressions. I will be very thankful in case you can help me out that Groovy scripting in J meter as well.
Hi Abhishek, sure I will check on that session
Hi Ragav, Excellent presentation. Very easy to understand. Thank you! Have a doubt, which tool will be the best for Web Service Load or Performance Testing (Load UI/LoadRunner/Jmeter..etc). Thanks!
Hi Nirmal, it depends on the need, features, budget etc. JMeter is free and lots of online support is available. However if you need to do geographical distribution, you will need multiple systems or go with some paid services like Blazemeter. Paid tools like LoadRunner have many out of the box features.
So it depends.
Hi Raghav, @9:45 , the list of printed methods from testRunner class is not having the testCase method. This testCase is very commonly used method right, why is its not available in the list of methods got printed?. Below are the methods names printed [cancel, equals, fail, getClass, getLog, getReason, getResults, getRunContext, getStartTime, getStatus, getTestCase,
getTestRunnable, getTimeTaken, gotoStep, gotoStepByName, hashCode, isRunning, notify, notifyAll, runTestStep, runTestStepByName,
setMockRunContext, setRunContext, start, toString, wait, waitUntilFinished]
Please clarify this doubt.
Hi, pls check the api doc here - www.soapui.org/apidocs/com/eviware/soapui/model/testsuite/TestRunner.html
Hello Raghav, I have written this code to execute the case, but getting null pointer exception error at statement number 4.
project = testRunner.testCase.testSuite.project ;
tcase = project.testSuites["TestSuite3"].testCases["TestCase2"] ;
tstep = tcase.getTestStepByName("GetCountryISOCode");
def status = tstep.run(testRunner, context)
def result = status.getStatus().toString();
log.info (" >>>> "+result)
Hi, just check if it is running your step. There can be some syntax or spelling issue (including spaces)
Hello RaghavPal, Do you have any online course where we can learn readyAPI with AWS console connection and checking cloudwatch?
Not yet on ReadyAPI Feroza
Sir for me the last demo didn't work the error is " Mon Dec 25 16:11:10 IST 2023:ERROR:An error occurred [Cannot get property 'testCase' on null object], see error log for details "
Abhishek
Here are the steps to address it:
1. Analyze Error Details:
Review Error Log: Inspect SoapUI's error log for specific line numbers and clues about the script's context.
Check Console Output: Look for additional error messages or stack traces that might provide more insights.
2. Identify Null Object:
Examine Variable Usage: Carefully review your script to determine where the testCase property is being accessed.
Verify Context: Ensure that the script is executing within a valid test case context where the testCase property should be accessible.
3. Common Causes and Solutions:
Incorrect Script Placement:
If the script is not within a test case or test step, it won't have access to the testCase property.
Move the script to the appropriate location within a test case or test step.
Missing Test Case Reference:
If the script is in a separate file or custom library, ensure it's properly referencing the test case object.
Pass the test case object as a parameter to the script or use appropriate methods to access it.
Script Execution Order:
If the script depends on other test steps or variables, verify that they are executing in the correct order.
Adjust the test case structure or use conditional logic to ensure proper execution flow.
Global Properties:
If you're using global properties, double-check their names and values to ensure they are defined correctly.
4. Debugging Tips:
Use Logging: Add log.info statements to print variable values and track script execution flow.
Isolate the Issue: Comment out parts of the script to narrow down the problematic code.
Test Incrementally: Build and test your script in small, manageable sections.
5. Additional Considerations:
SoapUI Version: If you're using an older SoapUI version, consider upgrading to avoid compatibility issues.
Script Complexity: For complex scripts, consider using techniques like modularization and error handling to improve readability and maintainability.
What is the difference between context and TestRunner as both the usage are same??
Hi Ashwin, pls check this stackoverflow.com/questions/25184307/what-t-is-the-difference-between-context-and-testrunner-in-soapui
Great tutorial, so seems to me that use of classes is more like static right? or by doing this testinit = tcase.getTestStepByName("anyclass"); you are creating an object of that type? Thanks!
So here a lot of inbuilt functions are provided by soapui. like getTestStepByName() is a function already available in an existing class and we can call it to get the value
Hi sir, i have a doubts
1. If we mentioned path parameter wrong in the uri what status code we get and we mentioned wrong Query parameter what status we get, we get 404 only for both path and query parameters or we get different status code.
2. what is the main difference between Bearer token and Token generated through API
Here are the answers to your SoapUI API testing questions:
1. Status Codes for Incorrect Parameters:
- Incorrect Path Parameter:
- Most likely results in a 404 Not Found status code, indicating the requested resource doesn't exist at the specified path.
- Incorrect Query Parameter:
- Varies depending on API implementation:
- Might return a 400 Bad Request status code if the parameter is invalid or essential for processing.
- Could return a 404 Not Found if the parameter is crucial for resource identification.
- Might ignore invalid parameters and return a 200 OK status code with potentially unexpected results.
Key takeaways:
- API documentation should specify expected status codes for different error scenarios.
- Testing with both correct and incorrect parameters is crucial for robust API testing.
2. Differences Between Bearer Token and API-Generated Token:
- Bearer Token:
- Self-contained access token representing authorization to access protected resources.
- Typically obtained through OAuth 2.0 or OpenID Connect flows.
- Used by adding "Bearer" keyword before the token in the Authorization header.
- Example: `Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...`
- API-Generated Token:
- Created by the API itself upon successful authentication or other actions.
- Specific usage varies depending on API design:
- Can be used for authorization, session management, or other purposes.
- Might be included in request headers, query parameters, or body data.
- Example: `Authorization: Token 1234567890abcdef`
Key takeaways:
- Bearer tokens are a standardized way to handle authorization in web APIs.
- API-generated tokens offer flexibility for custom authentication and authorization mechanisms.
- API documentation should clarify the types of tokens used and their intended usage.
Additional considerations for SoapUI:
- Use test steps to set appropriate headers for different token types.
- Assert expected status codes to verify API behavior in response to incorrect parameters.
- Leverage SoapUI's test suites and reporting features for comprehensive API testing.
@@RaghavPal Thank you for clear cut explanation sir
Hello, Ragav Thanks for the brilliant presentation But testStep.run(testRunner, context) not defined into hello class
I will check Mahmoud
can u plz create video on how perform IO operation in groovy
Hi Saifali, I have some File I/O videos here - czcams.com/play/PLhW3qG5bs-L8T6v6DgsZo93DgYDmOF9u4.html
Hi Raghav, I have one query.In the 'CallHello' test step , why did you write testStep.run(testRunner,Context) ? I could not understand the need for that line of code.
Thanks,
Minu
Hi Minu, log, context and testRunner are global variables and is present everytime in SoapUI. Now I may not go very deep but you can directly use them in your scripts as and when required and there are some in built syntaxes like the one above. You may check more in the documentation
Hi Raghav..
How to stop testcases running in infinite loop
It is not stopping..it is running continuously
Hi Roopa, if you do not find any option on the ui, you will have to close soapui and then fix the script
its very nice video. The Groovy script which we are using in SoapUI and Jenkins pipeline script , both are the same?
Thanks for watching Sreelatha. Groovy script is same wherever you use it.
Do we have the feature for auto suggestion, what we experience in eclipse
@Raghav Pal
Not on the free version Rijo
Okay Thanks 👍
Hi Raghav,
Thanks for the video.
Why are you passing testRunner and context as parameters in method testStep.run?
Hi Niaz, this is as per the structure of the method.
Hi I am getting while executing callHello groovy script java.lang.NullPointerException: cannot invoke menthod info () on null object line number 5 .
Pls check your code again and try to compare. What is line 5 of your code
As part of groovy scripting I'm unable to call 2 values from excel to do addition soap request . Please help. Its throwing error stating "org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script4.groovy: 3: unable to resolve class".
Its not able to recognize workbook even though i imported jxl.*
Hi Sreesatya , did you add excel library in bin folder and restart SoapUI
Hi Raghav is groovy scripting same in readyapi and soupui tools
Yes, ReadyAPI may have some more features like auto complete etc but you can use the same groovy scripts
@Automation Step by Step
project =testRunner.testCase.testSuite.project;
tcase = project.testSuites("TestSuite3").testCases("TestCaseName1");
hello = tcase.getTestStepByName("Hello");
hello.run(testRunner, context)
context.Hello.sayHello("Vipin")
For this Program i didn't got the proper output ;
groovy.lang.MissingMethodException: No signature of method: com.eviware.soapui.impl.wsdl.WsdlProject.testSuites() is applicable for argument types: (java.lang.String) values: [TestSuite3] Possible solutions: getTestSuites() error at line: 2
Hi Vipin, you have used circular brackets (). Try using square brackets []
tcase = project.testSuites("TestSuite3").testCases("TestCaseName1");
Hey can anyone answer that is it important to name groovyStep same name as the class itself
Hi Prashant, In case its related to some part in the video, pls mention the time stamp so I can check also try and check at your end
I'm getting java.lang.NullPointerException:Cannot invoke method sathi() on null object
Hi Puja where is this method sathi() coming from. Show the script
@@RaghavPal
Is there any difference happens, if
1) Right click on Test steps>Add Step>Groovy Script
2) Right click on Test case1, in Test suite 3 as in Vedio>Addstep>Groovy Script
I have done both one for class Hello and one for Calling the method, since the structure of Test suite remained same I didn't bother.
@@RaghavPal
I had not given Global Variable in order...like, log,context,test Runner in context.setProperty, now it executed, Tqsm😊
how to write this in a single line?
project = testRunner.testCase.testSuite.project ;
tcase = project.testSuites["TestSuite3"].testCases["TestCase1"] ;
hello = tcase.getTestStepByName("Hello");
Hi Anitha, I believe I replied to a similar question earlier. Just try to combine these like
hello = testRunner.testCase.testSuite.project.testSuites["TestSuite3"].testCases["TestCase1"].getTestStepByName("Hello")
Hi Raghav,
I need help with the blow can you help?
Test Step Name: Read Data from Excel file
Script Groovy Script
Web Services Method N/A
Activity
1. Read the inputs from a input.xls (define in project level property datafile) and set the values o the test case level properties x and Y
2. Run the Addition Test from groovy script
3. Fetch the result value from the response and set the fetched result value as the value to the test case level property z
4. Write the result value into the console log
Hi Sourav, do you need a groovy script for this. You will have to search and create it, I do not have anything handy
@@RaghavPal Thankyou Raghav Please let me know if I register for your CZcams Course will you be able to speak over chat and get help in solving codes like this , I want to learn this in details
Hi Sourav, due to huge no of messages, I might not be able to come over chat, but you can send me your queries and I can reply when I see them
how can we validate the REST request using JSON with the help of groovy script
Hi Krishna, you will have to get the response and then use JsonSlurper. You will get some groovy videos in this playlist - czcams.com/play/PLhW3qG5bs-L-Bt9T_bnyflQ0Te4VgFhKF.html
Can take some online help as well
Hi,
I am getting a null pointer exception when I try to call my method from another test case.
please help..
Solved it..Thanks a lot :D
Glad to know this Kshitij
Hey Raghav! Can you run python files with groovy script and can you use groovy script variable for testcase header valuer?
Hi, I did not exactly got your scenario and needs. In SoapUI, we use groovy scripting. You should be able to use it and code as per your needs.
Can we call this class from a different project if yes then how?
Hi Prashant, not sure from a diff proj, will need to check online
Hi Ragav
project =testRunner.testCase.testSuite.project;
tcase = project.testSuites("TestSuite3").testCases("TestCaseName1");
hello = tcase.getTestStepByName("Hello");
hello.run(testRunner, context)
context.Hello.sayHello("Vipin")
Output : got this below error please help .
groovy.lang.MissingMethodException: No signature of method: com.eviware.soapui.impl.wsdl.WsdlProject.testSuites() is applicable for argument types: (java.lang.String) values: [TestSuite3] Possible solutions: getTestSuites() error at line: 2
Hi Vipin, the syntax is wrong. it should be
tcase = project.testSuites["TestSuite3"].testCases["TestCaseName1"] ;
it is square brackets and not circular brackets
Hi Raghav ,
Is there a video where we can give multi data for an xml using groovy
I wanted to give multi data to single xml
And wanted to take the xml automatically from any datasoruce...using soapui free version...
Thanks in advance
Hi Narmada, pls explain your scenario in detail. An example will help
How to re,ad excel sheet data into groovy? pls help
Hi Steffy, I will plan to create a tutorial on that. You can try getting some online help meanwhile. Check this
stackoverflow.com/questions/46407278/how-to-get-data-from-excel-to-soapui-request
community.smartbear.com/t5/SoapUI-Pro/Get-xls-data-in-loop-in-groovy-script/td-p/27864
I get NullPointerException when I run callHello groovy... Error is at line -context.Hello.sayHello() Please help..
Hi Prathibha, need some logs to check this. Suggest pls see the video again to check if you missed something.
@@RaghavPal Sure Raghav..
@@RaghavPal context.setProperty("Hello", new Hello(log,context,testRunner)) - does this statement will add a custom property with the name Hello and value of the constructor to the groovy test step Hello? Because I checked my system and I did not find the custom property Hello under the groovy test step...
Hi Prathibha, this should not create a custom property available for user. It creates in context that will be available dynamically at runtime
I was getting NullpointerException ,because my groovy class was HelloGroovyScript but I called Hello then I changed to Hello then it worked .
Not working for me
Let me know the issue with logs Harsh
I got confused by listening "Hello" multiple times.
Sorry for that Balpreet