【问题标题】:How to print in python and behave如何在python中打印并表现
【发布时间】:2018-01-15 13:36:06
【问题描述】:
@then('I should be able to able to print with id "{el_id}"')
def step_impl(context, el_id):
    if is_element_id_there(context, 'el_id'):
        print(get_element_text_id(context, 'el_id'))
    else:
        raise Exception('Element with id: ' + el_id + ' not found')

我还通过定义变量使用了其他打印方式

@then('I should be able to able to print with id "{el_id}"')
def step_impl(context, el_id):
    if is_element_id_there(context, 'el_id'):
        var = get_element_text_id(context, 'el_id')
        print(var)
    else:
        raise Exception('Element with id: ' + el_id + ' not found')

注意:我已经在我的 bash 个人资料中添加了 --no-colors--no-capture

【问题讨论】:

标签: python python-behave


【解决方案1】:

在打印末尾添加换行符:

print(get_element_text_id(context, 'el_id') + '\n')

var = get_element_text_id(context, 'el_id')
print(var + '\n')

【讨论】:

    猜你喜欢
    • 2020-07-17
    • 2017-08-10
    • 2019-05-27
    • 1970-01-01
    • 1970-01-01
    • 2020-03-21
    • 1970-01-01
    • 2014-02-25
    • 2011-04-05
    相关资源
    最近更新 更多