1

I am trying to do a demo with Robot Framework which writes either Yes or No as a text to rows in Excel column number 31 (Excel-file containing a lot of music data on different columns) depending on whether a button is visible or not on a website after music track names from a different column of that same Excel-file are written to search input field automatically by Robot on that website. Searches are done as one search at time in for loop. So Robot reads one track name from Excel-file then does a search to search input field on a website and continues doing that in a loop as long as there are tracks to read in Excel column reserved for tracks. There is a button behaving differently on the site depending on search results so I would write either yes or no automatically to Excel-file based on value true or false regarding if the button is visible or not after each search.

Unfortunately I cannot post the full code as this is related to a functioning website in production but otherwise my code works and just this Excel writing part does not work yet. This demo is testing process automation for later actual usage.

So the idea is that if ${BUTTON VISIBLE} is returned as true then we would write Yes to Excel row. If it instead returns false then we would write No. Returning and logging true or false based on whether a button is visible after particular search works already.

My problem is this part of the code:

${BUTTON VISIBLE}=    Run Keyword And Return Status    Element Should Be Visible    xpath://html/body/ng-view/search-music/div/div[2]/div[1]/collapsible/div/song-list/md-list/div[1]/md-list-item/div
Log to console    ${BUTTON VISIBLE}
Run Keyword if    '${BUTTON VISIBLE}' == 'TRUE'    Write Data By Coordinates     ${EXCEL SHEET}    31    ${ROW}    Yes  

Problem is that if I would normally write this line to RIDE-editor

Write Data By Coordinates     ${EXCEL SHEET}    31    ${ROW}    Yes  

Then RIDE-editor would tell correctly what it needs as arguments after writing "Write Data By Coordinates" first and placing mouse cursor on that cell requiring the first argument after that. So for example that first red cell asks for sheet name just as expected. enter image description here

But if "Write Data By Coordinates" is instead located after "Run Keyword if" like this enter image description here

Then those arguments required by "Write Data By Coordinates" are instead "Optional arguments" so those are not in place correctly like "Write Data By Coordinates" would normally expect them. I anyway tried this version if it would still work as "Optional arguments" but no success.

In my experience a simple keyword like "Click Element" works well next to "Run Keyword if" but with a keyword like "Write Data By Coordinates" requiring many arguments it seems that this is not so simple. I tried to put "Write Data By Coordinates" part to the next line but then "Missing argument: name" is asked after "Run Keyword if '${BUTTON VISIBLE}' == 'TRUE'"

How could I correct my syntax to make "Run Keyword if" and "Write Data By Coordinates" work together?

Library for handling Excel is Open Pyxl Library.

Results logged by Robot regarding true or false (9 tracks are read from Excel and track number two leads to false just as expected):

True
False
True
True
True
True
True
True
True

Expected results in Excel column number 31 (after else for false case would be added to code above):

Yes
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes

Actual results at this time in Excel column number 31: Empty rows

jm90
  • 137
  • 11

1 Answers1

1

Try this:

Run Keyword If    '${BUTTON VISIBLE}'=='${TRUE}'    Write Data By Coordinates    ${EXCEL SHEET}    31    ${ROW}    Yes
...    ELSE IF    '${BUTTON VISIBLE}'=='${FALSE}'    Write Data By Coordinates    ${EXCEL SHEET}    31    ${ROW}    No

LaurencevdWel
  • 108
  • 1
  • 8