i have this code: Validate Weekly Scheduler Default Values [Arguments] @{elements}…
- User
i have this code: Validate Weekly Scheduler Default Values [Arguments] @{elements} {index} IN RANGE 0 {element}= Set Variable {index}] {expected_values}[{element} timeout=10s {element} value Should Be Equal As Strings {expected_value} Default value mismatch for element: {elements.length}' failed: AttributeError: 'list' object has no attribute 'length'
- Assistant
The error you're encountering:
Resolving variable '${elements.length}' failed: AttributeError: 'list' object has no attribute 'length'is because you're trying to access the
.lengthattribute of a list, which is invalid in Robot Framework (and in Python in general). In Python and Robot Framework, lists do not have a.lengthattribute. You should use the built-inlen()function instead.✅ Corrected Code:
Validate Weekly Scheduler Default Values [Arguments] @{elements} @{expected_values} ${length}= Get Length ${elements} FOR ${index} IN RANGE ${length} ${element}= Set Variable ${elements}[${index}] ${expected_value}= Set Variable ${expected_values}[${index}] Wait Until Element Is Visible ${element} timeout=10s ${actual_value}= Get Element Attribute ${element} value Should Be Equal As Strings ${actual_value} ${expected_value} Default value mismatch for element: ${element} ENDNotes:
- Changed
${elements.length}to:
This is the proper way to get the length of a list in Robot Framework.${length}= Get Length ${elements} - Also changed
${expected_values}from a scalar to a list variable using@{expected_values}, to be consistent with@{elements}.
Optional: Combine
FORand indexingAlternatively, if both lists always have the same size, you could simplify the loop using parallel iteration via
ZIP:FOR ${element} ${expected_value} IN ZIP @{elements} @{expected_values} Wait Until Element Is Visible ${element} timeout=10s ${actual_value}= Get Element Attribute ${element} value Should Be Equal As Strings ${actual_value} ${expected_value} Default value mismatch for element: ${element} ENDThis is cleaner and avoids explicit indexing.
Let me know if you'd like help handling mismatched list sizes or error handling!
- Changed
- User
i´m having this problem: Cannot have multiple varargs. to [Arguments] @{elements} @{expected_values}
- Assistant
Ah yes — that error occurs because Robot Framework only allows a single list variable (
@{}) in an[Arguments]declaration. When you try:[Arguments] @{elements} @{expected_values}you get:
Cannot have multiple varargs.✅ Solution
To fix this, you need to pass one list normally (
@{}) and the other as a scalar variable (${}), or concatenate both lists into a single list and separate them inside the keyword if needed.Here’s the most straightforward fix:
Use list variable for elements and scalar variable for expected values:
[Arguments] @{elements} ${expected_values}Then inside the keyword, treat
${expected_values}as a list if it is passed in that way.
✅ Updated Working Example:
Assuming
${expected_values}is a list:Validate Weekly Scheduler Default Values [Arguments] @{elements} ${expected_values} ${length}= Get Length ${elements} FOR ${index} IN RANGE ${length} ${element}= Set Variable ${elements}[${index}] ${expected_value}= Set Variable ${expected_values}[${index}] Wait Until Element Is Visible ${element} timeout=10s ${actual_value}= Get Element Attribute ${element} value Should Be Equal As Strings ${actual_value} ${expected_value} Default value mismatch for element: ${element} END✅ Even Better: Use ZIP iteration (if both are the same length)
If your keyword calling looks like this:
Validate Weekly Scheduler Default Values ... ${elements_list} ... ${expected_list}Then declare the arguments with both as scalar list variables:
[Arguments] ${elements} ${expected_values}And ZIP them for looping:
FOR ${element} ${expected_value} IN ZIP @{elements} @{expected_values} Wait Until Element Is Visible ${element} timeout=10s ${actual_value}= Get Element Attribute ${element} value Should Be Equal As Strings ${actual_value} ${expected_value} Default value mismatch for: ${element} END✅ Final Tips
- When calling the keyword with lists in your test case, you must pass them appropriately as scalars or lists:
*** Test Cases *** Test Default Values ${elements}= Create List input#mon input#tue input#wed ${expected}= Create List 08:00 09:00 10:00 Validate Weekly Scheduler Default Values ${elements} ${expected}Let me know if you want to use a dynamic argument handler (e.g. separating mixed arguments manually).
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.