def session(self, bundle_id=None, arguments=None, environment=None):
if bundle_id is None:<EOL><INDENT>sid = self.status()['<STR_LIT>']<EOL>if not sid:<EOL><INDENT>raise RuntimeError("<STR_LIT>")<EOL><DEDENT>http = self.http.new_client('<STR_LIT>'+sid)<EOL>return Session(http, sid)<EOL><DEDENT>if arguments and type(arguments) is not list:<EOL><INDENT>raise TypeError('<STR_LIT>')<EOL><DEDENT>if environment and type(environment) is not dict:<EOL><INDENT>raise TypeError('<STR_LIT>')<EOL><DEDENT>capabilities = {<EOL>'<STR_LIT>': bundle_id,<EOL>'<STR_LIT>': arguments,<EOL>'<STR_LIT>': environment,<EOL>'<STR_LIT>': True,<EOL>}<EOL>for k in list(capabilities.keys()):<EOL><INDENT>if capabilities[k] is None:<EOL><INDENT>capabilities.pop(k)<EOL><DEDENT><DEDENT>data = json.dumps({<EOL>'<STR_LIT>': capabilities<EOL>})<EOL>res = self.http.post('<STR_LIT>', data)<EOL>httpclient = self.http.new_client('<STR_LIT>'+res.sessionId)<EOL>return Session(httpclient, res.sessionId)<EOL>
Args:
    - bundle_id (str): the app bundle id
    - arguments (list): ['-u', 'https://www.google.com/ncr']
    - enviroment (dict): {"KEY": "VAL"}

WDA Return json like

{
    "value": {
        "sessionId": "69E6FDBA-8D59-4349-B7DE-A9CA41A97814",
        "capabilities": {
            "device": "iphone",
            "browserName": "部落冲突",
            "sdkVersion": "9.3.2",
            "CFBundleIdentifier": "com.supercell.magic"
        }
    },
    "sessionId": "69E6FDBA-8D59-4349-B7DE-A9CA41A97814",
    "status": 0
}

To create a new session, send json data like

{
    "desiredCapabilities": {
        "bundleId": "your-bundle-id",
        "app": "your-app-path"
        "shouldUseCompactResponses": (bool),
        "shouldUseTestManagerForVisibilityDetection": (bool),
        "maxTypingFrequency": (integer),
        "arguments": (list(str)),
        "environment": (dict: str->str)
    },
}