forked from appium-boneyard/sample-code
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhelpers.py
More file actions
18 lines (14 loc) · 680 Bytes
/
helpers.py
File metadata and controls
18 lines (14 loc) · 680 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import os
def ensure_dir(directory):
if not os.path.exists(directory):
os.makedirs(directory)
def take_screenhot_and_logcat(driver, device_logger, calling_request):
logcat_dir = device_logger.logcat_dir
screenshot_dir = device_logger.screenshot_dir
driver.save_screenshot(os.path.join(screenshot_dir, calling_request + ".png"))
logcat_file = open(os.path.join(logcat_dir, calling_request + "_logcat.log"), 'wb')
logcat_data = driver.get_log('logcat')
for data in logcat_data:
data_string = str(data['timestamp']) + ": " + str(data['message'])
logcat_file.write((data_string + '\n').encode("UTF-8"))
logcat_file.close()