To mark test Pass or Fail on Browserstack Appium Python-behave

487 Views Asked by At

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:[email protected]/automate/sessions/iOS-Appium.json".format(
            context.driver.session_id),
        json={"status": "completed", "reason": "Test Failed"})
else:
    requests.put(
        "http://username:[email protected]/automate/sessions/iOS-Appium.json".format(
            context.driver.session_id),
        json={"status": "completed", "reason": "Test Pass"})
2

There are 2 best solutions below

0
On BEST ANSWER

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"})
0
On

You could refer to the sample test in the link: https://gist.github.com/shawnlobo96/d7bea74b13556973146abbd900c5c4a9 and implement this at your side on similar lines.