@@ -58,7 +58,7 @@ def fetch_percy_dom():
58
58
# Take a DOM snapshot and post it to the snapshot endpoint
59
59
def percy_snapshot (driver , name , ** kwargs ):
60
60
session_type = is_percy_enabled ()
61
- if session_type is False : return # Since session_type can be None for old CLI version
61
+ if session_type is False : return None # Since session_type can be None for old CLI version
62
62
if session_type == "automate" : raise Exception ("Invalid function call - " \
63
63
"percy_snapshot(). Please use percy_screenshot() function while using Percy with Automate. " \
64
64
"For more information on usage of PercyScreenshot, " \
@@ -79,21 +79,24 @@ def percy_snapshot(driver, name, **kwargs):
79
79
'dom_snapshot' : dom_snapshot ,
80
80
'url' : driver .current_url ,
81
81
'name' : name
82
- }}, timeout = 30 )
82
+ }}, timeout = 600 )
83
83
84
84
# Handle errors
85
85
response .raise_for_status ()
86
86
data = response .json ()
87
87
88
88
if not data ['success' ]: raise Exception (data ['error' ])
89
+ if not data ["data" ]: return None
90
+ return data ["data" ]
89
91
except Exception as e :
90
92
print (f'{ LABEL } Could not take DOM snapshot "{ name } "' )
91
93
print (f'{ LABEL } { e } ' )
94
+ return None
92
95
93
96
# Take screenshot on driver
94
97
def percy_automate_screenshot (driver , name , options = None , ** kwargs ):
95
98
session_type = is_percy_enabled ()
96
- if session_type is False : return # Since session_type can be None for old CLI version
99
+ if session_type is False : return None # Since session_type can be None for old CLI version
97
100
if session_type == "web" : raise Exception ("Invalid function call - " \
98
101
"percy_screenshot(). Please use percy_snapshot() function for taking screenshot. " \
99
102
"percy_screenshot() should be used only while using Percy with Automate. " \
@@ -113,6 +116,9 @@ def percy_automate_screenshot(driver, name, options = None, **kwargs):
113
116
options ['consider_region_selenium_elements' ] = options ['considerRegionSeleniumElements' ]
114
117
options .pop ('considerRegionSeleniumElements' )
115
118
119
+ if 'sync' not in options :
120
+ options ['sync' ] = False
121
+
116
122
ignore_region_elements = get_element_ids (
117
123
options .get ("ignore_region_selenium_elements" , [])
118
124
)
@@ -134,16 +140,19 @@ def percy_automate_screenshot(driver, name, options = None, **kwargs):
134
140
'sessionCapabilites' : metadata .session_capabilities ,
135
141
'snapshotName' : name ,
136
142
'options' : options
137
- }}, timeout = 60 )
143
+ }}, timeout = 600 )
138
144
139
145
# Handle errors
140
146
response .raise_for_status ()
141
147
data = response .json ()
142
148
143
149
if not data ['success' ]: raise Exception (data ['error' ])
150
+ if not data ['data' ]: return None
151
+ return data ['data' ]
144
152
except Exception as e :
145
153
print (f'{ LABEL } Could not take Screenshot "{ name } "' )
146
154
print (f'{ LABEL } { e } ' )
155
+ return None
147
156
148
157
def get_element_ids (elements ):
149
158
return [element .id for element in elements ]
0 commit comments