1
@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
可能重複[如何在行爲(BDD)中看到print()語句](https://stackoverflow.com/questions/25150404/how-can-i-see-print-statements-in- behave-bdd) – Cynic
你添加了一個behave.ini文件嗎? https://stackoverflow.com/a/25291321/3838981 – Cynic