问题描述
请找到下面我在environment.py
文件中为after_scenario
添加的代码,我没有收到任何错误,但我的测试也没有在browserstack上标记为适当的状态
def after_scenario(context,scenario):
if scenario.status == Status.Failed:
requests.put(
"http://Username:Key@hub-cloud.browserstack.com/automate/sessions/iOS-Appium.json".format(
context.driver.session_id),json={"status": "completed","reason": "Test Failed"})
else:
requests.put(
"http://username:Key@hub-cloud.browserstack.com/automate/sessions/iOS-Appium.json".format(
context.driver.session_id),"reason": "Test Pass"})
解决方法
您可以参考链接https://gist.github.com/shawnlobo96/d7bea74b13556973146abbd900c5c4a9中的样本测试,并在自己的侧面以类似的方式实现。
,appium的REST API如下,更改了API调用后已解决了该问题
"http://'+username+':'+access_key+'@api-cloud.browserstack.com/app-automate/sessions/{}.json".format(
context.driver.session_id),data={"status": "completed","reason": "Test Failed"})