Please find the code below that I have added in environment.py
file for after_scenario
I do not get any error but neither are my tests marked with appropriate status on 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),
json={"status": "completed", "reason": "Test Pass"})
The REST API for appium is as follows, changing the API call made fixed the issue
"http://'+username+':'+access_key+'@api-cloud.browserstack.com/app-automate/sessions/{}.json".format(
context.driver.session_id), data={"status": "completed", "reason": "Test Failed"})