Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
457 views
in Technique[技术] by (71.8m points)

selenium - How to skip a testcase if a link is not present and go to next link in Robot framework

enter image description here

Scenario: There are 5 Links in the Home page: Link 1 Link 2 Link 3 Link 4 Link 5

Each of the above links are separate test cases, so there are a total of 5 test cases.

All the links may not present in all the sites, according to the requirements.

So I need to write a Robot framework test case which works dynamically for all the sites, Like 1 site may have 3 links only some has all the 5 links. So its like SKIPPING a particular Test case if that lisk is not present.

*** Keywords ***
Go to Manage Client Reports
Click Link    link:Manage Client Reports

Can anyone help.

question from:https://stackoverflow.com/questions/65916633/how-to-skip-a-testcase-if-a-link-is-not-present-and-go-to-next-link-in-robot-fra

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

In the upcoming Robot Framework Release 4.0 a new test status skipped will be introduced. Here is a brief status about the release:

Past due by 27 days 87% complete

Major release concentrating on adding the skip status (#3622), IF/ELSE (#3074) and enhancing the listener API (#3296 and #3538). Last major release to support Python 2.

So it can be ready any time soon now.

This is what you can have New SKIP status #3622. There will be a Skip If and a Skip keywords and more to be used.

How to skip tests

There are going to be multiple ways:

  • A special exception that library keywords can use to mark a single test to be skipped. See also #3685.
  • BuiltIn keyword Skip (or Skip Test and Skip Task) that utilizes the aforementioned exception.
  • BuiltIn keyowrd Skip If to skip based on condition.
  • When the skipping exception is used in a suite setup, all tests in the suite are skipped.
  • Command line option --skip to unconditionally skip tests based on tags. Similar to --exclude but skipped tests are shown in logs/reports with a skip status and not dropped from execution altogether.
  • Command line option --skiponfailure to skip tests if they fail. Similar effect than with the current --noncritical.

What about criticality

As already discussed in #2087, the skip status is very similar feature than Robot's current criticality concept. There are many people who would like to have both, but I don't think that's a good idea and believe it's better to remove criticality when skipping is added. Separate issue #3624 covers removing criticality and explains this in more detail. Colors

Skip status needs a specific color to match current pass (green) and fail (red). Yellow feels like a good candidate with a traffic light metaphor, but I'm open for other ideas and we could possibly change other colors as well. Probably should make colors configurable too -- currently only report background colors support it.

Report background color mentioned above needs some thinking as well. Currently it's either green or red, but with the added skip status we could use also yellow or whatever skip color we decide to use. Different scenarios where different colors could be used are listed below (assuming green/yellow/red scheme):

  • All tests pass. This is naturally green.
  • Any test fails. This is naturally red.
  • Any test is skipped (no failures). This probably should be green but could also be yellow.
  • All tests skipped. This could be yellow. Could also be green but that's a bit odd if all tests are yellow.

Depending on your deadlines you might won't be able to wait this release, nevertheless it is a good to know thing.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...