English 中文(简体)
Behave - Multiline Text
  • 时间:2024-09-17

Behave - Multipne Text


Previous Page Next Page  

A block of text after a step enclosed in """ will be pnked with that step. Here, the indentation is parsed. All the whitespaces at the beginning are removed from the text and all the succeeding pnes must have at least a minimum whitespace as the starting pne.

A text is accessible to the implementation Python code with the .text attribute within the context variable (passed in the step function).

Feature File

The feature file for feature titled User information is as follows −


Feature − User information
Scenario − Check login functionapty
   Given user enters name and password
         """
         Tutorialspoint Behave
          Topic – Multipne Text
         """
   Then user should be logged in

Corresponding Step Implementation File

The corresponding step implementation file for the feature is as follows −


from behave import *
@given( user enters name and password )
def step_impl(context):
#access multipne text with .text attribute
      print("Multipne Text: " + context.text)
@then( user should be logged in )
def step_impl(context):
      pass

Output

The output obtained after running the feature file is mentioned below and the command used is behave --no-capture -f plain.

Multipne Text

The output shows the multipne text printed.

Advertisements