JMeter -Groovy or Beanshell script for editing values in a excel - groovy

I am having a JMeter test case to upload an .xls file with multiple tabs of data . The data should be unique for each iteration
Each tab has 100 values as
ASDFG0002
ASDFG0002
POIUY0002
The ‘0002’ needs to be replaced for each iteration in multiple tabs .
How can I achieve this using Groovy/beanshell script

Not knowing the exact structure of your Excel document it's not possible to come up with the exact code so I can only provide generic instruction:
Download tika-app.jar and drop it into JMeter Classpath
Restart JMeter to pick the .jar up
Amend the content of the file using Apache POI API and save the file under the different name
Configure HTTP Request sampler to use the new file
Here are examples of reading/writing Excel documents from Java/Groovy:
Busy Developers' Guide to HSSF and XSSF Features
How to Implement Data Driven Testing in your JMeter Test

Related

JMeter jp#gc-WebDriver Sampler — Run the Webpage from MS Excel Spreadsheet

I have the Webpage that need to perform the multi test cases for automation test and currently need to hard code the text variables from WebDriver Sampler by Groovy. And I would like to know that JMETER WebDriver can pickup the data from MS. Excel and performing the test? Like says the I need key in the login page and select the items from dropdown box from the webpage. The next step will be confirm the order by input the Credit Cards information. Thanks.
The easiest is to convert MS Excel file into CSV file, if you're able to do it - you can read the values using CSV Data Set Config
If the file is coming from external location and it's in one of binary formats (.xls or .xlsx) - it's still can be done, but you will have to do some scripting like:
Download tika-app.jar to JMeter Classpath
Restart JMeter to pick the .jar up
Use Apache POI library for reading data from Excel. The code will be different for different file formats and your Excel structure so I can only provide a couple of links with examples and snippets:
Busy Developers' Guide to HSSF and XSSF Features
How to Implement Data Driven Testing in your JMeter Test

Handling Excel Spreadsheets with Cucumber

I am planning to work on the Cucumber feature file with Groovy code (Katalon Studio) for step definitions. I wanted to use the excel file in Cucumber file or to see is there any other option to use it.
I have not yet tried as of now any other option. I am thinking just passing the cucumber step file without any parameter and then using the excel file with in the step definition and access excel file and get the corresponding value.
I see there is a post in this forum suggesting to use QMetry Automation Framework for this type of question. But it does not look like this will help on this or should I use the passing the row index from cucumber file and based on that retrieve the value. Please guide on this.
Handling excel spreadsheets with Cucumber Scenario Outline
You should know that this is not supported by Cucumber.
As specified in the FAQ:
"We advise you not to use Excel or csv files to define your test cases; using Excel or csv files is considered an anti-pattern.
One of the goals of Cucumber is to have executable specifications. This means your feature files should contain just the right level of information to document the expected behaviour of the system. If your test cases are kept in separate files, how would you be able to read the documentation?
This also means you shouldn’t have too many details in your feature file. If you do, you might consider moving them to your step definitions or helper methods. For instance, if you have a form where you need to populate lots of different fields, you might use the Builder pattern to do so."
If you are using cucumber java 5+ you can add qaf-cucumber dependency. It should work with groovy as well. It will enable to have examples from external source like CSV, XML, JSON, EXCEL, DB.

Can Data Export from SQL Developer to Excel be scheduled?

I have to run almost 50 queries daily for daily reports and copy-paste the data into Excel sheets. Is there a way to schedule a job on SQL Developer that exports data from all the queries in an Excel Workbook?
You could link the excel spreadsheets to your queries so they automatically update themselves.
Insert > Data from External Source. I do this with SQL Server a lot, and you can do it with Oracle too if you know the connection strings.
I would comment, but I dont have the rep yet.
I would advise using your operating system to schedule the task. Assuming that this is Windows (as you want to write to Excel) then you can use Task Scheduler to set off a cmd script or powershell script which can call SQLPLUS passing in a parameter for the the sql file that you wish to run. It would not be too difficult to output this to a CSV file which can be opened in Excel. If you actually need to write the data to a .xlsx (or similar) file then there are options (e.g. Python libraries that can do this), but it will not be as straight forward.
I am not sure exactly what part of this you need help with, so can I suggest that you consider the steps below, if you want to proceed do some research and have an attempt at each step and then post a question for each that you are stuck on with details of what you have tried:
Schedule a job from your operating system;
Write a script to call SQLplus and execute a .sql file;
Change query output to csv and redirect to file (or find a way to write directly to an Excel file if this is what you need to do);

A Batch File which contains a Lotus Script

Is it possible to run a batch file containing a lotus script? Would it also be possible to include a lotus script and then another language for example ksh's? If yes then could you please give me some samples or tutorials on how to do it?
What I need to do is this:
There is already an existing batch file which contains a ksh's that updates the value in an excel files every time it is executed.
What I need to do is include two new functions, first I need to download the excel file from a rich text in a document of lotus notes, then run the functions above written in ksh's after that
I need to re-upload it or update the excel file which is in the lotus notes document. I used lotus script for the added functionality.
I also don't know how to use or create ksh's and batch files. Thanks.
I personally would turn around the logic: why not use a scheduled LotusScript or Java- Agent, detach the file from the richtextitem and then run the ksh from there (e.g. using the Shell- Command of LotusScript)...
That way you can code the stuff you need in the languages that are best for your purpose. You could even attach the ksh to a configuration document and detach it on the fly Or build the ksh completely on the fly (with write commands)... That makes this solution replicate to any number of servers without having to distribute your ksh to each of them...
LotusScript runs only within a scripting host engine provided by IBM Lotus, but LotusScript isn't the only way to access Lotus Notes data.
You haven't said what platform you are running ksh on. You mention that you are operating on Excel files, so if you are running your scripts on Windows it may be possible for you to use the Lotus Notes COM classes. Those classes are almost exactly the same as the back-end classes that you would have available in LotusScript, but I have no idea whether any version of ksh (not to mention whatever version you are using) supports the CreateObject call or any other way to access COM classes.
However, a ksh script can certainly run Java programs, and there are Java classes for Lotus Notes that are (again) almost exactly the same as the back-end classes that you would use in LotusScript. It seems to me that the obvious thing for you to do is write a small Java program to retrieve the file from the Domino server, and another Java program to re-upload it after. Then have your script run the program to do the download, run the commands to modify the Excel data, and then run the program to do the upload.

Exporting data to existing Excel file

I have a system with an Excel spreadsheet template file which is used for invoicing. I would like the user to be able to click a button on an Xpage, which will then open the spreadsheet and enter the latest invoicing data in Excel. I don't mind if Excel is either the application on their machine or on the server, but my preference would be the application locally on their machine.
I've looked into Xagents, as I feel this is probably the answer. I know they can be used to create Excel but I have not been able to locate any mention of opening an Excel file, and entering data into specific cells.
Is this possible?
EDIT: you can use Apache POI for editing and creating Microsoft Office documents. This is a java project which gives you a handle to office documents and this can be used using java.
A good starting point can be the blog of Christian Guedemann from webgate:
http://guedebyte.wordpress.com/2012/09/17/documents-and-spreadsheets-with-xpages-building-the-kernel-part-ii/
(end of edit)
The only way I KNOW and tried to write data from Notes to Excel is exporting the data to an HTML page and setting the Content Type accordingly (e. g. as described here (there are a lot more resources available for taht):
http://www.dominoguru.com/pages/developer2010_xpagexlsexport.html
I am not sure if this is of help but it seems that this project can help you:
http://www.openntf.org/internal/home.nsf/project.xsp?action=openDocument&name=ZK%20Spreadsheet%20for%20XPages
As far as I can see this project can load Excel files from XPages - and then it should also be possible to edit the files.
Besides that the only solution I can think of is a Notes Agent that is called from the XPage. This agent can then run in background and do all the excel stuff. After running, the XPage can show a link to the Excel file. Actually this is the solution I would consider to implement - but maybe others step in with better answers here.
You don't want to introduce a dependency on Excel in your application -- wouldn't work with an iPad front-end. Rather have a look at the ZK Spreadsheet, it will fulfill your needs.
However if you have to have Excel, then you need a roundtrip solution: load the Excel from an URL (probably generated by an XAgent (?) and save it back. The saving back part is the tricky one. Normal HTTP doesn't allow that. What you need there is a webDAV capable server. Watch out for a project on OpenNTF soon (just clearing IBM legal) that provides webDAV.
However the ZK Spreadsheet looks much better for your needs.
I have a sample database at the following URL --> http://www.nnsu.com/nnsusite.nsf/%24%24OpenDominoDocument.xsp?documentId=B65507CB2DE15B3286257986005F061D&action=openDocument
Download the APCC.nsf. This will allow you to create/read a new EXCEL spreadsheet and then stream the resulting file to the requesting browser. There is not need to have EXCEL or office installed on the Server.
THe examples create a new workbook, but you can also store a "template" on the server or in a notes document and use it as a starting point and then save it to a document or stream it to the requesting browser.
With Apache POI you can read/write to a spreadsheet using data from the notes document the process is initiated from.

Resources