file upload with geb - file-upload

Recently I've got the issue with upload file with geb.
Documentation say me that it's impossible to upload file by usual way but exist another way as in the link bellow
http://www.gebish.org/manual/current/#file-upload
$('form').fieldName = file.absolutePath
but after this way carried out I've got the next exception. It's very strange according the geb docs
No signature of method: java.lang.String.value() is applicable for argument types: ([C) values: [/tmp/template4951246218168115052.pdf]
Possible solutions: valueOf([C), valueOf(boolean), valueOf(char), valueOf(double), valueOf(float), valueOf(int)
groovy.lang.MissingMethodException: No signature of method: java.lang.String.value() is applicable for argument types: ([C) values: [/tmp/template4951246218168115052.pdf]
Possible solutions: valueOf([C), valueOf(boolean), valueOf(char), valueOf(double), valueOf(float), valueOf(int)
at geb.content.PageContentSupport.propertyMissing(PageContentSupport.groovy:52)
at geb.Page.propertyMissing(Page.groovy:99)
at com.avax.functional.specs.client.DigitalSignatureSpec.chose contract and upload some pdf-file(DigitalSignatureSpec.groovy:35)
Any idea?
I'll be very grateful.
Thanks

Related

How to run a TestCafe test with CLI that contains a metadata array

I have a test with the following metadata:
test.meta({ type: 'smoke', testcase: ['tc01', 'tc02'] });
The testcase metadata contains an array of id's that I would like to use them as filter for running the test using any of the values using the command line interface:
testcafe --test-meta testcase=tc01
testcafe --test-meta testcase=tc02
These two command lines should run the same test, however they don't work. Is there another way to approach to this solution?
Reading this discussion on TestCafe's github page, it seems that metadata has to be only single value strings: https://github.com/DevExpress/testcafe/issues/3267 The issue is then closed and the last explanation was that such a feature request is not very clear because:
In addition, the particular case you are addressing is a bit tricky, what will be the user expected behaviour?, To match only when the array has all the passed values? or when the array is equal to that values (ie: don't have any extra one)?.
Such an option is not mentioned in the official documentation either: https://devexpress.github.io/testcafe/documentation/guides/basic-guides/organize-tests.html#specify-test-metadata
That leads me to believe you can't really achive what you're asking for as of June 2020.

Returning Variable from Feature File With Multiple Scenarios - Karate

We already know that scenarios are run paralelly. But we had the case where we need to return variables from feature files (that are gonna be called from another feature file).
We had multiple scenarios in the feature file as below:
#mutation
Feature: Test GraphQL Create Item
Background:
Given url baseUrl
* configure headers = { Authorization: '#(token)' }
#negative
Scenario: Create item unauthorized
* configure headers = { Authorization: ""}
#Features calling function and others
And match response.errors[0].message == errorUnauthorized
Scenario: Create story authorized
#Features calling function and others
And def idItem = response.data.CreateItem.id
We are reusing the feature file above to obtain variable to be used on another feature file. However it seems that the other feature files fail intermittently complaining the variables obtained from the other feature file is null.
My assumption is that the returned variable is not returned properly since there are more than one scenarios on the feature file. We tried deleting the #negative scenario and have only exactly 1 scenario. Suddenly the intermittent failures gone.
Is there any way to avoid this intermittent failures while still retaining the ability to run scenarios paralelly?
Thanks
Can't say without seeing your code. But you can try using the #parallel=false annotation in the "calling" feature file: https://github.com/intuit/karate#parallelfalse
Otherwise this may be a bug in Karate - so please follow this process: https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue

How to pass the background response value of the to another feature json in function value using Karate

I have got the response in the background to one of the request and passing to the function for polling purpose and need to run until specific condition met. In that function, I need to pass the values to the calling feature JSON file
while (true) {
var result = karate.call('extractProgress.feature') packageid; -- package id
is response of another request
I followed the similar way as mentioned but in that not passing any parameter.
https://github.com/intuit/karate/blob/933d3803987a736cc1a38893e7039c4b5e5132fc/karate-demo/src/test/java/demo/polling/polling.feature
But i am getting the below error
feature(com.intuit.karate.testng.KarateTestngTest):
java.lang.RuntimeException: javascript evaluation failed: packageid,
ReferenceError: "packageid" is not defined in at line number 1
Input for call inside js should be given as
karate.call("<featureFile>",yourInputVaraible);
refer this on doc
https://github.com/intuit/karate#the-karate-object
It sounds wrong to me, maybe you have a typo.
Also please read the docs carefully. Only JSON is supported as a call argument.
The best way for you to get support is to follow this process, else no one can help you with the limited info you seem to be providing in your questions.
https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue

Jmeter Beanshell: Accessing global lists of data

I'm using Jmeter to design a test that requires data to be randomly read from text files. To save memory, I have set up a "setUp Thread Group" with a BeanShell PreProcessor with the following:
//Imports
import org.apache.commons.io.FileUtils;
//Read data files
List items = FileUtils.readLines(new File(vars.get("DataFolder") + "/items.txt"));
//Store for future use
props.put("items", items);
I then attempt to read this in my other thread groups and am trying to access a random line in my text files with something like this:
(props.get("items")).get(new Random().nextInt((props.get("items")).size()))
However, this throws a "Typed variable declaration" error and I think it's because the get() method returns an object and I'm trying to invoke size() on it, since it's really a List. I'm not sure what to do here. My ultimate goal is to define some lists of data once to be used globally in my test so my tests don't have to store this data themselves.
Does anyone have any thoughts as to what might be wrong?
EDIT
I've also tried defining the variables in the setUp thread group as follows:
bsh.shared.items = items;
And then using them as this:
(bsh.shared.items).get(new Random().nextInt((bsh.shared.items).size()))
But that fails with the error "Method size() not found in class'bsh.Primitive'".
You were very close, just add casting to List so the interpreter will know what's the expected object:
log.info(((List)props.get("items")).get(new Random().nextInt((props.get("items")).size())));
Be aware that since JMeter 3.1 it is recommended to use Groovy for any form of scripting as:
Groovy performance is much better
Groovy supports more modern Java features while with Beanshell you're stuck at Java 5 level
Groovy has a plenty of JDK enhancements, i.e. File.readLines() function
So kindly find Groovy solution below:
In the first Thread Group:
props.put('items', new File(vars.get('DataFolder') + '/items.txt').readLines()
In the second Thread Group:
def items = props.get('items')
def randomLine = items.get(new Random().nextInt(items.size))

sesame http repository connection - begin()

I have the following code for creating connection and starting a transaction:
org.openrdf.repository.RepositoryConnection con = repo.getConnection();
con.begin();
The line con.begin() produces the following error:
No signature of method: org.openrdf.repository.http.HTTPRepositoryConnection.begin() is applicable for argument types: () values: []
Possible solutions: wait(), find(), wait(long), is(java.lang.Object), print(java.io.PrintWriter), print(java.lang.Object)
The call is legitimate, I don't know how I could fix this. I considered not using the call, but was told the call is necessary to keep commit from becoming automatic. I'm not sure what is the best solution here, any help is much appreciated.
I fixed it by using def con =, instead of org.openrdf.repository.RepositoryConnection.
Also, I had a conflict for three different jar files (httpclient, httpcore, httpmime), removing older copies of them solved the issue.