This question already has an answer here:
In Karate Scenario Outline test, how to pass param values in the Examples table through a variable
(1 answer)
Closed 1 year ago.
I want to run my scenario with all the images that i have in my resource folder. meaning every time hitting same api with different image(converting them to base64encoding first) .But as this images already are in resource folder than it does not make sense to save with some name or records in csv for scenario outline purpose. Can i call a my own function (having code to take the image from resource folder and convert it into base64) in Examples section , So that for every image it will hits the same api again.
Yes. First write some java code to get a list of the image files. You can refer this code for ideas: https://stackoverflow.com/a/65035825/143475
If that is too hard, then just create a CSV file with a list of paths. Let me say that Karate is designed for testing, but you seem to be expecting something else. Karate is not a "general purpose" programming language. But it can be made to do extreme things by Java interop.
One you have a JSON array, then it can be used as the data-source for the Examples: section: https://github.com/intuit/karate#json-array-data-source
You can refer other answers for Base64 conversion: https://stackoverflow.com/a/46452864/143475
All the things you want to do is possible, but please do some research and try. And the next time you ask a question, please show what you tried and give examples instead of just a broad question, thanks.
Related
I wrote a feature and a reusable feature, and this is the result in karate summary report below.
enter image description here
However, I want to pass variable value to the report sub-title and makes it more readable. Below is what I want to get.
enter image description here
Is there any way we can customize the report in this way?
I have read the question on passing variable to karate feature line and scenario name. However it doesnt work on reusable feature, because for reusable feature it wont show as a normal scenario in karate report....
Thanks a lots!
Yes, in Karate we recommend that re-use is done only for "utilities" and not the main domain flows in your test.
Do consider using a Scenario Outline to loop like this, because it will appear in the report as a "normal" Scenario.
An enhancement released in 1.3.0.RC2 may give you what you are looking for: https://github.com/karatelabs/karate/issues/1905
Else please assume this is not supported, but open-source code contributions are welcome.
I am basically trying to learn data parametrization in robot framework (mostly with web based testing as the context). I have 4 points which i am looking to get covered . All the four point are related to each other a lot.
First one - A code problem
I was looking to iterate a values of a list variable using for loop and was unable to access the nth value .
I am able to use the following with no errors:
Input Text //textarea[#id="MainContent_txtAddress"] #{Address}[1]
But when i am using a for loop to access the values I am getting this error:
Starting test: RobotFrameworkcode.Nsure.ForLoop
20150105 18:26:05.484 : FAIL : Resolving variable '${jobcode[i]}' failed: NameError: name 'i' is not defined
Ending test: RobotFrameworkcode.Nsure.ForLoop
The for loop snippet which is causing the error .
ForLoopTest
: FOR ${i} IN Range |0| |1|
\ Log to Console #{jobcode[i]}
Is there a better way to access the value of a list variable at n th element .
Are list variables similar to arrays ?
I want to pass values to textboxes in a data entry form in
parametrized format through excel sheet or csv or through a
collection of list variables representing a page, Is that possible
in robot framework ? Need help with examples and sample code on the
same . I could not find much content on the internet regarding the
same.
Any other ideas on how others did data parametrization in general in
robot framework. What robot framework tools or concepts where used
for the same ?
Thirdly,I would like to know if there are any good tutorials or
websites or videos to help learn robot framework in general . The
official documentation is good , but i am looking for more content
example wise,so as to enable the beginners to be able to relate
faster with the concepts.
1. NameError: name 'i' is not defined
When you use the extended variable syntax, everything inside the curly braces is evaluated by the python interpreter. However, the i in your code is a robot variable, not a python variable. Also, to access an individual element of an array you need to use $ rather than #. In order to do what you want, you need to do it like this:
Log to Console ${jobcode[${i}]}
2. Parameters from excel
You can create a robot library that reads data from a csv file. You can also do that with a .xls file. See this answer for an example of reading a csv file: https://stackoverflow.com/a/21859360/7432
3. Any other ideas on how others did data parametrization?
My team uses YAML files to define test data. It's also possible to read from XML files, or any other format that is readable via python. Robot lets you expose python methods as keywords, so anything you can do in python you can do in a robot test.
4. I would like to know if there are any good tutorials or websites or videos
Asking for pointers to tutorials and websites is off topic for stack overflow. However, are you familiar with the following resources?
http://robotframework.org/#documentation
https://github.com/robotframework/QuickStartGuide/blob/master/QuickStart.rst
https://blog.codecentric.de/en/2012/03/robot-framework-tutorial-overview/
Parameterization can be achieved using a csv or excel data source. Our team implemented it using excel, sharing the reference code that can help
http://www.ufthelp.com/2016/01/robot-framework-working-with-excel_28.html
I want to evaluate my content blocks before running my test suite but the closures' property names is in bytecode already. I'm ooking for the cleanest solution (compared with parsing source manually).
Already tried solution outlined in this post (and I'd still wind up doing some RegEx/parsing) but could only get it to work via script execution engine. It failed in IDE and GroovyConsole. Rather than embedding a Groovy script in project's code, I thought I'd try using Geb's native classes.
Is building on the suggestion about extending Geb Navigators here viable for Geb's PageContentSupport class whose contentTemplates contain a LinkedHashMap of exactly what I need? If yes, would someone provide guidance? If no, any suggestions?
It is currently not possible to get hold of all content elements for a given page/module. Feel free to create an issue for this in Geb's bug tracker, but remember that all that Geb can provide is either a list of content element names or a map from these names to closures that create these elements.
Having that information isn't a generic solution to your problem because it's possible for content elements to take parameters and there are situations where your content elements will be available on the page only after some other actions are performed (for example you have to click on button to reveal a section of a page that uses ajax to retrieve it's content). So I'm afraid that simply going over all elements and checking if they don't throw any errors will not cut it.
I'm still struggling to see what would "evaluating" all content elements prior to running the suite buy you. Are you after verifying that your content elements still work to get a faster feedback than running the whole suite? I'm pretty sure that you won't be able to fully automate detection of content definitions that don't work anymore. In my view it will be more effort than it's worth.
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Server Generated web screenshots?
Whenever i use
goo.gl to shorten urls
, i see a screenshot of the url's page!
It's not usual screenshot - there're no UI elements - only the page itself!
My question: How do they do it? What is the general logic behind generating this screenshot(raster image)?
#valentinas no. i'm not after implementation. I'd like to get a
general idea how it's done! (and also, without using canvas element) –
DrStrangeLove 6 mins ago
General idea: you take a browser rendering engine (webkit is pretty good, here's one of the implementations: http://phantomjs.org/) and instead of outputting the result to UI you take it and dump it to file.
I have a question that pertains to scripting. For the sake of clarity I'll just start off with a bit of what I'm trying to do. We have a number of testing environments and projects going on in each environment that trying to keep track of what is where is becoming increasingly difficult.
In order to try and straighten this out I was going to create a script that would pull the comments/description (that is where our developers put the code branch,project name,and date of the build into. This is what we use for versioning) of the dll. Then I would dump this information into a simple table on an html page which would be pulled as a web part.
I was using VBS to perform this and I was able to successfully pull a version number and dump it into an HTML page. However, I have not been able to find any information on how to do this for the comments or description (using Server 2k3 and 2k8) fields.
So my question is if there is a way to pull this information using VBS, or would there be a better scripting language that would allow this to be done.
Thanks very much in advance.
I don't think exactly what you're asking for is possible, however this may be helpful:
http://www.activexperts.com/activmonitor/windowsmanagement/adminscripts/filesfolders/files/