Sessions Api¶
- class bsapi.app_automate.appium.sessions.AppAutomateSession(name=None, duration=None, os=None, os_version=None, browser_version=None, browser=None, device=None, status=None, hashed_id=None, reason=None, build_name=None, project_name=None, logs=None, browser_url=None, public_url=None, appium_logs_url=None, video_url=None, device_logs_url=None, app_details=None)¶
BrowserStack Session
- Parameters
name (str) –
duration (str) –
os (str) –
os_version (str) –
browser_version (str) –
browser (str) –
device (str) –
status (str) –
hashed_id (str) –
reason (str) –
build_name (str) –
project_name (str) –
logs (str) –
browser_url (str) –
public_url (str) –
appium_logs_url (str) –
video_url (str) –
device_logs_url (str) –
app_details (
bsapi.app_automate.appium.apps.UploadedApp) –build (
bsapi.app_automate.appium.builds.Build) –project (
bsapi.app_automate.appium.projects.Project) –
- static by_id(session_id=None)¶
Get the Session for the given ID
Example:
driver = webdriver.Remote(url, desired_caps) session_id = driver.session_id driver.quit() session = Session.by_id(session_id)
- Parameters
session_id (str) – Unique Session ID
- Returns
bsapi.app_automate.appium.sessions.Session
- get_appium_logs()¶
Get the Appium logs from BrowserStack for the Session
Example:
session = Session.by_id(session_id) with session.get_appium_logs() as response: with open("appium.log", "wb") as f: f.write(response.content)
- Returns
Response object containing the Appium Logs
- Return type
requests.Response
- get_device_logs()¶
Get the Appium logs from BrowserStack for the Session
Example:
session = Session.by_id(session_id) with session.get_device_logs() as response: with open("device.log", "wb") as f: f.write(response.content)
- Returns
Response object containing the Device logs from BrowserStack
- Return type
requests.Response
- get_network_logs()¶
Get the Network logs from BrowserStack for the Session
Example:
session = Session.by_id(session_id) with session.get_network_logs() as response: with open("network.log", "wb") as f: f.write(response.content)
- Returns
Response object containing the Network logs for BrowserStack
- Return type
requests.Response
- get_session_logs()¶
Get the Session logs from BrowserStack
Example:
session = Session.by_id(session_id) with open("session.log", "wb") as f: with session.get_logs() as r: f.write(r.content)
- Returns
Response object containing the session logs from BrowserStack
- Return type
requests.Response
- get_video()¶
Get the video from BrowserStack for the Session
Example:
session = Session.by_id(session_id) with session.get_video() as response: with open("BrowserStack.mp4", "wb") as f: f.write(response.content)
- Returns
Response object containing the Video recording for the BrowserStack session
- Return type
requests.Response
- save_appium_logs(file_name=None)¶
Save the appium logs to the file system
Example:
session = Session.by_id(session_id) session.save_appium_logs("appium.log")
- Parameters
file_name –
- save_device_logs(file_name=None)¶
Save the device logs to the file system
Example:
session = Session.by_id(session_id) session.save_device_logs("device.log")
- Parameters
file_name –
- save_network_logs(file_name=None)¶
Save the network logs to the file system
Example:
session = Session.by_id(session_id) session.save_network_logs("network.log")
- Parameters
file_name –
- save_session_logs(file_name=None)¶
Download the session logs from BrowserStack to the file name
Example:
session = Session.by_id(session_id) session.save_session_logs("session.log")
- Parameters
file_name – File name for the logs to be saved to
- Returns
None
- save_video(file_name=None)¶
Save the video of the session to the file system
Example:
session = Session.by_id(session_id) session.save_video("BrowserStack.mp4")
- Parameters
file_name –
- class bsapi.app_automate.appium.sessions.AppProfilingData(ts=None, cpu=None, mem=None, mema=None, batt=None, temp=None)¶
App profiling data entry
- Parameters
timestamp (str) –
cpu (str) –
memory (str) –
memory_available (str) –
battery (str) –
temperature (str) –
- class bsapi.app_automate.appium.sessions.SessionStatus¶
Represents the Session Status options
- Parameters
passed (str) – Passed
failed (str) – Failed
- class bsapi.app_automate.appium.sessions.SessionsApi¶
Wrapper around the Sessions endpoint
- classmethod delete(session_id=None)¶
Delete the session from BrowserStack
Example:
response = SessionApi.delete(session_id) if response.status == "ok": print("The session has been deleted")
- Parameters
session_id – The unique id for the session
- Returns
delete status message
- Return type
bsapi.app_automate.appium.responses.DeleteResponse
- classmethod details(session_id=None)¶
Get the details for a session provided the ID
Example:
session = SessionsApi.details(session_id)
- Parameters
session_id – the hashed id for the session
- Returns
Session Object
- Return type
- classmethod get_appium_logs(build_id=None, session_id=None)¶
Get the Appium logs from BrowserStack
Example:
with SessionsApi.get_appium_logs(build_id, session_id) as response: with open("appium.log", "w") as f: f.write(response.content)
- Parameters
build_id – The build id
session_id – The session id
- Returns
The raw response object from the request
- Return type
requests.Response
- classmethod get_device_logs(build_id=None, session_id=None)¶
Get the device logs from BrowserStack
Example:
with SessionsApi.get_device_logs(build_id, session_id) as response: with open("device.log", "w") as f: f.write(response.content)
- Parameters
build_id – The build id
session_id – the session id
- Returns
returns the raw response object for the request
- Return type
requests.Response
- classmethod get_network_logs(build_id=None, session_id=None)¶
Get the network logs from BrowserStack
Example:
with SessionsApi.get_network_logs(build_id, session_id) as response: with open("network.json", "w") as f: f.write(response.content)
- Parameters
build_id – The build id
session_id – The session id
- Returns
The raw response object from the request
- Return type
requests.Response
- classmethod get_profiling_data(build_id=None, session_id=None)¶
Get the profiling data from BrowserStack
Example:
profiling_data = SessionsApi.get_profiling_data(build_id, session_id) for data_entry in profiling_data: print(data_entry.mem)
- Parameters
build_id – The Build ID
session_id – The Session ID
- Returns
returns a list of profiling data entries
- Return type
- classmethod get_text_logs(build_id=None, session_id=None)¶
Get the BrowserStack logs for the session
Example:
with SessionsApi.get_text_logs(build_id, session_id) as response: with open("session.log", "w") as f: f.write(response.content)
- Parameters
build_id – the unique build id
session_id – the unique session id
- Returns
returns the raw response object for the request
- Return type
requests.Response
- classmethod update_status(session_id=None, status=None, reason=None)¶
Update the status of a session
Example:
session = SessionsApi(session_id, SessionStatus.passed)
- Parameters
session_id – The session id
status (str) – The new status. Use
SessionStatusfor available statusesreason – reason for the new status
- Returns
Updated Session object