Saturday 15 March 2014

robotframework - how to use "Run Keyword If" in robot framework -



robotframework - how to use "Run Keyword If" in robot framework -

i started working on robot framework , need help please. trying utilize "try keyword if" next examples see online show solution in single line whereas have columns , rows in ride.

if have button id "current status" on current page want go url www.xyz.com , perform action . confusion when write "run keyword if" in first cell of test case in ride, should write in sec column? should "page should contain" ? or "page should not contain"

please allow me know info missing above.

if using run keyword if, sec column must python look rather keyword. explained in keyword documentation. illustration (using pipe-separated format clarity):

| | run keyword if | ${answer} == 42 | go | http://www.example.com

if want run keyword if page has element id of "current status", need first determine if page has element or not, , utilize in expression. there many ways this. documentation shows how utilize "run keyword , ignore error", this:

| | ${status} | ${value}= | run keyword , ignore error | page should contain | //*[@id='current status'] | | run keyword if | '${status}' == 'pass' | go | http://www.example.com

there other ways accomplish same thing. example, count of how many items on page contain id, , run keyword if count greater zero:

| | # determine if on page has id of 'current status' | | ${count}= | matching xpath count | //*[@id='current status'] | | # if there @ to the lowest degree 1 item on page id, go xyz.com | | run keyword if | ${count} > 0 | go | http://www.example.com

if want perform multiple steps, such go page , validation, straight-forward thing create separate keyword, , phone call that.

... | | run keyword if | ${count} > 0 | validation *** keywords *** | validation | | go | http://www.example.com | | page should contain | hello, world

robotframework

No comments:

Post a Comment