0

Is there any option to skip step during an executing scenario in behave (Python). I have the following scenario:

Scenario: Opening and closing driver by clicking and sliding
    When swipe right
    Then drawer should appear
    When swipe left
    Then drawer should disappear
    Given part is for Android # now only Android executes, iOS not
    When click hamburger
    Then drawer should appear
    When click outside drawer
    Then drawer should disappear

Right now I have some variable passed with context and I check if tit's true before each step like this:

@when('swipe right')
def step_slide_right(context):
    dc = context.device_commands
    if dc.check_if_this_is_the_platform(context.run_test_for):
        dc.slide_right()

Is there any function to skip inside before_step(context,step) like skip_step, to not call if dc.check_if_this_is_the_platform(context.run_test_for):... in each step.

Omi Harjani
  • 737
  • 1
  • 8
  • 20
  • Possible duplicate of [Skip a behave step in the step implementation](https://stackoverflow.com/questions/26504047/skip-a-behave-step-in-the-step-implementation) – Cynic Mar 19 '18 at 21:52

1 Answers1

0

I don't think there is a @skip_if for steps but from what I can tell there is a feature added in 1.2.5 that might work for your purposes. You would outline two scenarios, and tag them @use.with_os=Android and @use.with_os=iOS (See Active Tag Logic).

@use.with_os=Android
Scenario: Opening and closing driver by clicking and sliding
    When swipe right
    Then drawer should appear
    When swipe left
    Then drawer should disappear
    Given part is for Android # now only Android executes, iOS not
    When click hamburger
    Then drawer should appear
    When click outside drawer
    Then drawer should disappear

@use.with_os=iOS
Scenario: Opening and closing driver by clicking and sliding
    When swipe right
    Then drawer should appear
    When swipe left
    Then drawer should disappear

Then include -D os=Android or -D os=iOS on your run command (See userdata).

And it will use the scenario tagged for that device.

Cynic
  • 6,779
  • 2
  • 30
  • 49