I want to navigate through all the rows and get the values of Product ID one by one (In first script). Here I am using loop to get the values and processing it.
Then want to save all the Product IDs in different variables in variable.robot file
Finally want to call these product IDs in multiple other scripts. In few scripts I need one or two id’s and in couple of scripts I need them to bring one by one in loop.
I was thinking about list but not able to acheive it.
Please suggest if any solution is with list too.
Want to know how to save multiple outputs received from For Loop to different variables.
also want to know how to save these values from first script to variables.robot so it will be easy call these values any other scripts.
I am getting list in one script but how to send it to variables.robot or call these values one by one in other scripts?
@{list} Create List
Append To List ${list} ${ProductID}
You can save to a CSV file and then read them.
Or you can save as variable file (.yml, .json, .py) and they import. In this case you need to have more complex data structures.
${rows} = get element count xpath=//*[@id="YearlyReport"]/tbody/tr
sleep 2
log to console Total Rows ${rows}
${ProductID}= Read Csv File To List ProductID.csv
FOR ${element} IN @{ProductID}
Log To Console ${element}[0]
FOR ${rowno} IN RANGE 1 ${rows}+1
Input Text xpath=//input[@placeholder='Search ...'] ${element}[0]
sleep 5
${Details} = Get Text xpath=//*[@id="YearlyReport"]/tbody/tr[${rowno}]/td[10]
log to console In Search details of ${element}[0] is ${Details}
I am getting below error
List ‘${element}’ has no item in index 0. If I change value to 1 then it gives same error List ‘${element}’ has no item in index 1.
Language: English
*** Settings ***
Library CSVLibrary
Library OperatingSystem AS OS
*** Test Cases ***
Save data
[Setup] Create File ${CURDIR}${/}ProductID.csv
${ProductID}= Create List A1 B1 C1 D1 E1
Append To Csv File ${CURDIR}${/}ProductID.csv ${ProductID}
Read data
${ProductID}= Read Csv File To List ${CURDIR}${/}ProductID.csv
Log Many ${ProductID}
# We get [['A1', 'B1', 'C1', 'D1', 'E1']]
# So, we must select element 0 of this list
${products}= Set Variable ${ProductID[0]}
FOR ${element} IN @{products}
Log ${element}
END
[Teardown] OS.Remove File ${CURDIR}${/}ProductID.csv