I am getting this error when executing Testng in selenium - selenium-webdriver

Data Provider public java.lang.Object[] as.get() must return either Object[][] or Iterator<Object>[], not class java.lang.Object;

As the documentation says:
The Data Provider method can return one of the following two types:
An array of array of objects (Object[][]) where the first dimension's
size is the number of times the test method will be invoked and the
second dimension size contains an array of objects that must be
compatible with the parameter types of the test method. This is the
cast illustrated by the example above.
An Iterator<Object[]>. The only
difference with Object[][] is that an Iterator lets you create your
test data lazily. TestNG will invoke the iterator and then the test
method with the parameters returned by this iterator one by one. This
is particularly useful if you have a lot of parameter sets to pass to
the method and you don't want to create all of them upfront.
So, I suppose you current data provider method is returning Object instead of one of the 2 supported types.

Related

Jmeter Property with array of values

Requirement: Need to store 50+ values to a Jmeter property and use with idx
In the case of normal variable we can use Country_1 or Country_2.
Do we have any function to set an array of values to jmeter Property and how to get value using index?
Note: In this case,value has to be used in different thread group.
Your ArrayList initialization is not correct, you should be doing something like:
List myList = Arrays.asList('India', 'USA', 'UK')
There is no putObject method in props shorthand (which is basically an instance of java.util.Properties class so you will need to amend your code like:
props.put('Middle', myList)
Once done you will be able to access individual list members using __groovy() function like:
${__groovy(props.get('Middle').get(0),)} - for first member
${__groovy(props.get('Middle').get(1),)} - for second member
${__groovy(props.get('Middle').get(2),)} - for third member
etc.
Demo:
See Apache Groovy - Why and How You Should Use It article for more details on using Groovy scripting in JMeter tests.

Uncaught Cannot convert Array to Object[][] when passing array of arrays to range.setValues()

Desired Behaviour
Populate Google Sheet with array of arrays from a Javascript file.
// in js file (within google apps script project)
var aoa = [["row_01_val01", "row_01_val02", "row_01_val03"],
["row_02_val01", "row_02_val02", "row_02_val03"]]; // etc
google.script.run.withSuccessHandler(console.log("success")).populateSpreadsheet(aoa);
// in code.gs
// define target_range (ignore discrepancies between example values above)
var target_range = active_sheet.getRange(2, 1, 834, 20);
// set values of target_range
target_range.setValues(aoa);
Current Behaviour
// chrome developer tools (firefox/firebug not supported at work)
Uncaught Cannot convert Array to Object[][]
Question
I'm unable to post more specific code due to work restrictions (cannot access SO from work, or take code home, hence the pseudo code), but are there any common 'gotchas' when it comes to passing an array of arrays from a Javascript file to Code.gs for use in setValues()?
What I've Tried
In the js file, console.log(typeof(aoa)) returns object just before passing it to populateSpreadsheet() within Code.gs, and then Logger.log(aoa) within populateSpreadsheet() also returns object
Example:
var outer_array = [];
inner_array = [1,2,3];
outer_array.push(inner_array);
typeof(outer_array);
"object"
I've tried to refactor the code several times, but am wondering if there are any common gotchas like size constraints, quotas, or timeouts or some other 'quirk' I haven't considered?
This question and answer, for example, required the array of arrays to be reconstructed before passing it to setValues() (I tried this but it didn't work in my instance):
https://stackoverflow.com/a/11066322/1063287
Another thing I considered is that I'm using splice()(MDN reference) to add some values to the inner array's within Code.gs, so I'm not sure if that somehow changes the type permissible to be passed to setValues()?

Storing array data in firebase, and how ID's are generated

I have a set of objects in my firebase data that all have an array under them. When I create the initial object, I create the initial array with its first object with a line of code like this:
ref.child('items').set([{firstobject: id123}])
this seems to set the id to zero, as the first item in the array. However when I later try to push() a new item to the array with this line of code, I get a more complex id (ZwPiVMIrzbSdvfwxkts).
ref.child('items').push(someNewObject);
In your first line of code, you're calling the Firebase.set() method passing it a JavaScript array that contains a single object.
In your second line of code, you're calling the Firebase.push() method with an object.
Given that Firebase lists/collections are not the same as JavaScript arrays, you end up with a mismatch.
Unlike JavaScript arrays, Firebase's lists are architected to scale well in highly concurrent, multi-user scenarios. I'd recommend to use them instead of arrays from the start.
ref.child('items').push({firstobject: id123});
ref.child('items').push(someNewObject);
With this snippet, all your items will be stored under so-called push ids.

Delphi SOAP Client adding items to dynamic array

I'm currently developing a client for a SOAP service.
The WSDL import works fine, but I'm facing the problem that I need to add items to a dynamic array.
The declaration in delphi:
Array_Of_attributWS = array of attributWS;
dienstleistungWS = class(TRemotable)
private
[..]
public
[..]
published
property attributeWS: Array_Of_attributWS
Index(IS_OPTN or IS_UNBD or IS_NLBL or IS_UNQL)read GetattributeWS
write SetattributeWS stored attributeWS_Specified;
I want to add an item to attributeWS from an other unit.
To add an item I use this code:
SetLength(dynArray, Length(dynArray)+1);
dynArray[High(dynArray)] := item;
But it wont let me, I get the following error:
E2197 Constant object cannot be passed as var parameter
Is there a way to add an item easy to the dynamic array?
Or is there a way to cast the array to a list so that I can just do .Append(item)?
Delphi Version XE6
Thanks!
If you check the SetattributeWS implementation you will see it simply gets your dynamic array as a const parameter, stores it and marks an internal boolean variable as true (indicating the parameter has been informed).
The const part is the one that causes the E2197 error you are seeing.
The best option is to use a local dynamic array variable of the same type and then:
set its length to the actual length of attributeWS + 1.
copy the original items from attributeWS to the local variable, and then add the new item.
assign this variable to the attributeWS property.
Actually, it would be better to not assign the dynamic array to the request property until you have it filled with all the necessary elements, but that may depend on your needs.

different methods in passing parameters in Cakephp

I am using cakephp v1.26.
I got a function in a controller like this:
class testingsController extends AppController{
function testing($id=null){
$recieved = $id;}
}
I am not sure if there are any better ways to pass a parameter to the Action testing.
But I have come across some web sites and got these two methods.
Is there any difference in the following parameter passing methods?
1. url/testings/testing/1
2. url/testings/testing:1
url/testings/testing/1
With standard routes, this will call TestingsController::testing(1).
This is standard parameter passing, any parameters beyond /:controller/:action/ are passed "as-is" to the called action.
/controllers/action/param1/param2 corresponds to
ControllersController::action($param1, $param2)
url/testings/testing:1
With standard routes, this will call TestingsController::index() and
set $this->params['named']['testing'] to 1. This is known as a named parameter.
Named parameters can be passed in any order. These two URLs are equivalent:
url/testings/testing:1/foo:2
url/testings/foo:2/testing:1
They will not be passed to the function, as in function testing($id = null). $id will be null. They're only available in the $this->params['named'] array.
The first example you have will pass it as a numeric parameter
$this->params[0]; // 1
The second will pass a named pair, rather like an array
$this->params['testing']; // 1
You can use either for different things. You'll notice that the paginator uses key:val paired parameters when sorting columns and pages.
There is a little bit of further info in the Book, http://book.cakephp.org/2.0/en/development/routing.html#passed-arguments

Resources