How to report failed testcase in jira using automation - selenium

I am automating a website using selenium webdriver with java, I want to write the result "Pass" or "Fail" in excel sheet. How can i automate the reporting of a failed test case in JIRA by taking the status from excel sheet.

Since you are already writing to an excel file, I understand that you are able to access the contents of the Excel Sheet. If this is not completed yet, you might want to consider using http://poi.apache.org/spreadsheet/index.html for this purpose. Once you have the status of the test cases, you can use the JIRA API to create bugs https://ecosystem.atlassian.net/wiki/display/JRJC/Home. A more specific example of how to do this is mentioned here (https://developer.atlassian.com/display/JIRADEV/JIRA+REST+API+Example+-+Create+Issue).
However, since a bug (defect) usually requires more information than a simple PASS / FAIL, I would suggest that you might want to collect more information like the stack trace etc and save it in the excel file (or an XML file) when the test fails.
Which test runner are you using? If it is JUnit / TestNG, I believe a XML file is created by default for a test run, which might have some of this information.

You can use 'Apache POI' to read cells from Excel sheet and 'Jira Client' to update status in Jira.
'Jira Client' is a JIRA REST based client library for Java. You can read more about this here: https://github.com/rcarz/jira-client/blob/master/README.md

Related

Automating HPALM Tasks with UFT

I am automating an SAP Application using UFT Tool, I have completed my Automation work in UFT and I have placed all my automation Test Scripts in HP ALM Shared Repository under the folder name Test labs and I am executing my Test scripts from HPALM.
I have a plan to automate the task of launching the HPALM and Run the Test automatically from my local machine so that the user need not need to log into the HPALM each time when he runs a Particular scenario.
In order to achieve this I have an idea to create a file on my local machine containing the name of the test cases and when selecting the Test case the script should open the ALM Connection and Run the Test, But I don't find the appropriate way to achieve this since I am a new to HPALM and VB.
Any Ideas are appreciated and thank you in advance.
Well, in Simpler terms you need to automate using OTA.
1 - You will need a file containing all the test cases and a Flag to check which test case to run - This file can be an Excel file.
2 - Write a VBScript to initiate ALM Connection, Read the cases to be executed from an excel file and execute its test scripts.
Read OTA for more details
Check out my answer for How to use 'Export to HP ALM' Addin for Excel using Macro or VbScript
You may be able to find ideas on connecting ALM through VBScript (I have used a macro, you can use a .VBS (Notepad) )
Let me know if you need more help

SoapUI - Increase property value for each test case

I want to use a property ('currentId') which has a certain start value. For each test case the value should be increased by 1. I can do that by adding an extra test step in each test case which increases the value but that would be much copy paste. The code for that would be (see reference):
def uniqueUserPortion = testRunner.testCase.testSuite.project.getPropertyValue("currentId")
// convert it to an Integer, and increment
def uniqueUserPortionInc = uniqueUserPortion.toInteger() + 1
// set the property back as string
testRunner.testCase.testSuite.project.setPropertyValue("currentId", uniqueUserPortionInc.toString())
To avoid that copy&paste I've added the code above to the Load Script of the project but it doesn't work:
testSuite.testCases.each {
*code above*
}
What can I do to use the code in one script/call for all test cases?
I could define the property as the start value plus the test case ID but that would be a definition in each test case again since I can not reference the #TestCase#ID in project level/property.
Issue with what your are trying
Load Script of the project is executed once when you import the project into soapui workspace. So, this approach does not work.
As you rightly mentioned, either you need to have it in a separate step of the each test case or you can add the same code as setup script. Yes, it is copy paste only
It is possible to achieve easily using SoapUI NG which pro edition using Event feature.
Then your next question may be : how to do it in Open Source edition of SoapUI.
Here is an soapuiExtensions which I did sometime ago which allows you do the same without having to copy paste for each test case in open source edition.
All you need do is have your groovy script into a specific file called 'TestCaseBeforeRun.groovy'. That means, the script is executed before running each test case.
For more details refer README
This soapuiExtensions library allows users to have some additional functionality in soapUI(free edition) tool, like soapui pro allows to do something before, after doing something.
For eg: User may want to do something before running a test case or after running a test case etc by implementing appropriate groovy script as required. Allow me to add an example here. Usually user may want to add credentials for the request step automatically, see the script samples/scripts/TestSuiteTestStepAdded.groovy
How to use this library:
set SOAPUI_HOME environment variable.
copy lib/SoapUIExtListeners.jar file under $SOAPUI_HOME/bin/ext directory
copy samples/listeners/custom-listeners.xml file under $SOAPUI_HOME/bin/listeners directory
copy samples/scripts directory under $SOAPUI_HOME
And implement appropriate groovy script available under $SOAPUI_HOME/scripts. Refer Mappings file in order to implement respective groovy script.
Note: for windows users, you may need to check %SOAPUI_HOME%\bin\soapui.bat which actually overwrites SOAPUI_HOME, need to fix soapui.bat script if requires.
Uses jdk 7, soapUI 4.5.1, and groovy 1.8.9
Dependency
log4j
UPDATE: this is realted to the note in the above.
As it was mentioned in the note, soapui.bat overrides SOAPUI_HOME environment variable on windows, needs to be tweaked a bit. May be you want to copy that groovy file under %SOAPUI_HOME%\bin\scripts (this is without tweaking soapui.bat)and retry. If your machine is linux then it should work if you copy the groovy file under $SOAPUI_HOME/scripts directory

How to find all places where variable is used in JMeter scenario?

I use JMeter to record HTTP scenario and do load testing. Now I need to correlate some values using Regular Expression Extractor, for example ${secure_id}, but I don't know how to find all requests where this variable is used. I can substitute this step by step, but it is necessary for me to do it automatically in all places where it is used. Thanks for any answer
You could open your TestPlan.jmx file with text editor notepad++ for example and find+replace all occurrences of ${secure_id} here is an example
Have you seen "Search" option in JMeter's main menu? It's available since JMeter 2.9 if not earlier
As #Boyan suggests JMeter scripts are XML files so you can use your favourite text editor for bulk replacing hardcoded recorded value with the variable
You can use a 3rd-party recorder which has SmartJMX mode. The main feature is automatic correlation of any detected entities. See How to Cut Your JMeter Scripting Time by 80% for details.

How to pass random parameters to SilkTest Workbench or Classic Record&Play Scenario

I am new to SilkTest and I don't have any scripting background. What I need to do is to record some test cases and then play them to check my system. After getting used to it, I plan to learn scripting and dive into it, but first things first.
What I need is to pass random generated (or randomly read from a text file or pre-defined) parameters into the recordins so that every time I run the tests, different parameters are used. For example, there is a component in which I write some letters and the component filters the results based on the text. Then, I select one of the results. Now, instead of recording the same letters everytime, how can I use random given parameters?
Thanks
What you are looking for is called Active Data in Silk Test.
It allows enhancing your visual tests with external data, for example from an Excel file.
ActiveData testing enables you to leverage existing data in external files as input for powerful, comprehensive application testing solutions. ActiveData testing enables you to perform multiple transactions against test applications using a different set of data for each transaction without writing complicated code or compromising existing data.
You can find an introduction to Active Data in the online documentation or in the tutorial video.
I have a question, what version of Silk Test are you using, also, what client are you using (Silk Test Workbench, Silk4Net or Silk4J). Each of these clients has the ability to receive parameters from an external source whether it is from a command line or from an external data file.
You indicate that you want random data, do you really mean random data or external data? If it is random data that you want you probably need to use a random number/string generator for the client that you are working with (.Net code for Workbench and Silk4Net and Java code for Silk4J).

Prefill new test cases in Selenium IDE

I'm using Selenium IDE 2.3.0 to record actions in my web application and create tests.
Before every test I have to clear all cookies, load the main page, log in with a specific user and submit the login form. These ~10 commands are fix and every test case needs them, but I don't want to record or copy them from other tests every time.
Is there a way to configure how "empty" test cases are created?
I know I could create a prepare.html file or something and prepend it to a test suite. But I need to be able to run either a single test or all tests at once, so every test case must include the commands.
Ok I finally came up with a solution that suits me. I wrote custom commands setUpTest and tearDownTest, so I only have to add those two manually to each test.
I used this post to get started:
Adding custom commands to Selenium IDE
Selenium supports object-oriented design. You should create a class that takes those commands that you are referring to and always executes those, in each of the tests that you are executing you could then make a call to that class and the supporting method and then execute it.
A great resource for doing this is here.