2

How can I click element by element in the list where the locator looks like this:

id=${NameFirst.replace(" ", ""}_${NameLast.replace(" ", "")}

    *Keywords*
    | Get all first and last names
    | | ${Name} | Query Master Database
    | | ... | 
    | | [Return] | ${Name[0][0]} | ${Name[0][1]}

    *Test Case*
    | Click element by element
    | | :FOR | ${NameElement} | IN | @{NameElementList}
    | | ${NameFirst} | ${NameLast}= | Get all first and last names
    | | set suite variable | ${NameFirst}
    | | set suite variable | ${NameLast}
    | | Click Element | id=${NameFirst.replace(" ", ""}_${NameLast.replace(" ", "")}

When I run test case it clicks the first element only

INFO ${Name} = [['AAA', 'BBB'], ['CCC', 'DDD']]
INFO    ${NameFirst} = AAA
INFO    ${NameLast} = BBB
1
  • You are not using ${NameElement} anywhere in the FOR loop which makes the loop pretty much useless.
    – Harri
    Feb 10, 2014 at 6:11

1 Answer 1

0

First, it appears that your loop isn't formatted correctly. The body of the loop needs an extra level of indentation. The following example illustrates:

*Test Case*
| Click element by element
| | :FOR | ${NameElement} | IN | @{NameElementList}
| | | ${NameFirst} | ${NameLast}= | Get all first and last names
| | | set suite variable | ${NameFirst}
| | | set suite variable | ${NameLast}
| | | Click Element | id=${NameFirst.replace(" ", ""}_${NameLast.replace(" ", "")}

Here the lines belonging to forloop needs be be spaced out leaving one cell. PFAFor loop example

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.