docstring
stringlengths
52
499
function
stringlengths
67
35.2k
__index_level_0__
int64
52.6k
1.16M
Function path: Network.setDataSizeLimitsForTest Domain: Network Method name: setDataSizeLimitsForTest WARNING: This function is marked 'Experimental'! Parameters: Required arguments: 'maxTotalSize' (type: integer) -> Maximum total buffer size. 'maxResourceSize' (type: integer) -> Maximum per-resource size. No return value. Description: For testing.
def Network_setDataSizeLimitsForTest(self, maxTotalSize, maxResourceSize): assert isinstance(maxTotalSize, (int,) ), "Argument 'maxTotalSize' must be of type '['int']'. Received type: '%s'" % type( maxTotalSize) assert isinstance(maxResourceSize, (int,) ), "Argument 'maxResourceSize' must be of type '['int']'. Received type: '%s'" % type( maxResourceSize) subdom_funcs = self.synchronous_command('Network.setDataSizeLimitsForTest', maxTotalSize=maxTotalSize, maxResourceSize=maxResourceSize) return subdom_funcs
762,295
Function path: Network.getCertificate Domain: Network Method name: getCertificate WARNING: This function is marked 'Experimental'! Parameters: Required arguments: 'origin' (type: string) -> Origin to get certificate for. Returns: 'tableNames' (type: array) -> No description Description: Returns the DER-encoded certificate.
def Network_getCertificate(self, origin): assert isinstance(origin, (str,) ), "Argument 'origin' must be of type '['str']'. Received type: '%s'" % type( origin) subdom_funcs = self.synchronous_command('Network.getCertificate', origin= origin) return subdom_funcs
762,296
Function path: Database.executeSQL Domain: Database Method name: executeSQL Parameters: Required arguments: 'databaseId' (type: DatabaseId) -> No description 'query' (type: string) -> No description Returns: 'columnNames' (type: array) -> No description 'values' (type: array) -> No description 'sqlError' (type: Error) -> No description
def Database_executeSQL(self, databaseId, query): assert isinstance(query, (str,) ), "Argument 'query' must be of type '['str']'. Received type: '%s'" % type( query) subdom_funcs = self.synchronous_command('Database.executeSQL', databaseId =databaseId, query=query) return subdom_funcs
762,299
Function path: IndexedDB.requestDatabaseNames Domain: IndexedDB Method name: requestDatabaseNames Parameters: Required arguments: 'securityOrigin' (type: string) -> Security origin. Returns: 'databaseNames' (type: array) -> Database names for origin. Description: Requests database names for given security origin.
def IndexedDB_requestDatabaseNames(self, securityOrigin): assert isinstance(securityOrigin, (str,) ), "Argument 'securityOrigin' must be of type '['str']'. Received type: '%s'" % type( securityOrigin) subdom_funcs = self.synchronous_command('IndexedDB.requestDatabaseNames', securityOrigin=securityOrigin) return subdom_funcs
762,300
Function path: IndexedDB.clearObjectStore Domain: IndexedDB Method name: clearObjectStore Parameters: Required arguments: 'securityOrigin' (type: string) -> Security origin. 'databaseName' (type: string) -> Database name. 'objectStoreName' (type: string) -> Object store name. Returns: Description: Clears all entries from an object store.
def IndexedDB_clearObjectStore(self, securityOrigin, databaseName, objectStoreName): assert isinstance(securityOrigin, (str,) ), "Argument 'securityOrigin' must be of type '['str']'. Received type: '%s'" % type( securityOrigin) assert isinstance(databaseName, (str,) ), "Argument 'databaseName' must be of type '['str']'. Received type: '%s'" % type( databaseName) assert isinstance(objectStoreName, (str,) ), "Argument 'objectStoreName' must be of type '['str']'. Received type: '%s'" % type( objectStoreName) subdom_funcs = self.synchronous_command('IndexedDB.clearObjectStore', securityOrigin=securityOrigin, databaseName=databaseName, objectStoreName=objectStoreName) return subdom_funcs
762,302
Function path: IndexedDB.deleteDatabase Domain: IndexedDB Method name: deleteDatabase Parameters: Required arguments: 'securityOrigin' (type: string) -> Security origin. 'databaseName' (type: string) -> Database name. Returns: Description: Deletes a database.
def IndexedDB_deleteDatabase(self, securityOrigin, databaseName): assert isinstance(securityOrigin, (str,) ), "Argument 'securityOrigin' must be of type '['str']'. Received type: '%s'" % type( securityOrigin) assert isinstance(databaseName, (str,) ), "Argument 'databaseName' must be of type '['str']'. Received type: '%s'" % type( databaseName) subdom_funcs = self.synchronous_command('IndexedDB.deleteDatabase', securityOrigin=securityOrigin, databaseName=databaseName) return subdom_funcs
762,303
Function path: CacheStorage.requestCacheNames Domain: CacheStorage Method name: requestCacheNames Parameters: Required arguments: 'securityOrigin' (type: string) -> Security origin. Returns: 'caches' (type: array) -> Caches for the security origin. Description: Requests cache names.
def CacheStorage_requestCacheNames(self, securityOrigin): assert isinstance(securityOrigin, (str,) ), "Argument 'securityOrigin' must be of type '['str']'. Received type: '%s'" % type( securityOrigin) subdom_funcs = self.synchronous_command('CacheStorage.requestCacheNames', securityOrigin=securityOrigin) return subdom_funcs
762,304
Function path: CacheStorage.deleteEntry Domain: CacheStorage Method name: deleteEntry Parameters: Required arguments: 'cacheId' (type: CacheId) -> Id of cache where the entry will be deleted. 'request' (type: string) -> URL spec of the request. No return value. Description: Deletes a cache entry.
def CacheStorage_deleteEntry(self, cacheId, request): assert isinstance(request, (str,) ), "Argument 'request' must be of type '['str']'. Received type: '%s'" % type( request) subdom_funcs = self.synchronous_command('CacheStorage.deleteEntry', cacheId=cacheId, request=request) return subdom_funcs
762,306
Function path: CacheStorage.requestCachedResponse Domain: CacheStorage Method name: requestCachedResponse Parameters: Required arguments: 'cacheId' (type: CacheId) -> Id of cache that contains the enty. 'requestURL' (type: string) -> URL spec of the request. Returns: 'response' (type: CachedResponse) -> Response read from the cache. Description: Fetches cache entry.
def CacheStorage_requestCachedResponse(self, cacheId, requestURL): assert isinstance(requestURL, (str,) ), "Argument 'requestURL' must be of type '['str']'. Received type: '%s'" % type( requestURL) subdom_funcs = self.synchronous_command('CacheStorage.requestCachedResponse', cacheId=cacheId, requestURL=requestURL) return subdom_funcs
762,307
Function path: DOMStorage.setDOMStorageItem Domain: DOMStorage Method name: setDOMStorageItem Parameters: Required arguments: 'storageId' (type: StorageId) -> No description 'key' (type: string) -> No description 'value' (type: string) -> No description No return value.
def DOMStorage_setDOMStorageItem(self, storageId, key, value): assert isinstance(key, (str,) ), "Argument 'key' must be of type '['str']'. Received type: '%s'" % type( key) assert isinstance(value, (str,) ), "Argument 'value' must be of type '['str']'. Received type: '%s'" % type( value) subdom_funcs = self.synchronous_command('DOMStorage.setDOMStorageItem', storageId=storageId, key=key, value=value) return subdom_funcs
762,308
Function path: DOMStorage.removeDOMStorageItem Domain: DOMStorage Method name: removeDOMStorageItem Parameters: Required arguments: 'storageId' (type: StorageId) -> No description 'key' (type: string) -> No description No return value.
def DOMStorage_removeDOMStorageItem(self, storageId, key): assert isinstance(key, (str,) ), "Argument 'key' must be of type '['str']'. Received type: '%s'" % type( key) subdom_funcs = self.synchronous_command('DOMStorage.removeDOMStorageItem', storageId=storageId, key=key) return subdom_funcs
762,309
Function path: DOM.querySelector Domain: DOM Method name: querySelector Parameters: Required arguments: 'nodeId' (type: NodeId) -> Id of the node to query upon. 'selector' (type: string) -> Selector string. Returns: 'nodeId' (type: NodeId) -> Query selector result. Description: Executes <code>querySelector</code> on a given node.
def DOM_querySelector(self, nodeId, selector): assert isinstance(selector, (str,) ), "Argument 'selector' must be of type '['str']'. Received type: '%s'" % type( selector) subdom_funcs = self.synchronous_command('DOM.querySelector', nodeId= nodeId, selector=selector) return subdom_funcs
762,310
Function path: DOM.setNodeName Domain: DOM Method name: setNodeName Parameters: Required arguments: 'nodeId' (type: NodeId) -> Id of the node to set name for. 'name' (type: string) -> New node's name. Returns: 'nodeId' (type: NodeId) -> New node's id. Description: Sets node name for a node with given id.
def DOM_setNodeName(self, nodeId, name): assert isinstance(name, (str,) ), "Argument 'name' must be of type '['str']'. Received type: '%s'" % type( name) subdom_funcs = self.synchronous_command('DOM.setNodeName', nodeId=nodeId, name=name) return subdom_funcs
762,311
Function path: DOM.setNodeValue Domain: DOM Method name: setNodeValue Parameters: Required arguments: 'nodeId' (type: NodeId) -> Id of the node to set value for. 'value' (type: string) -> New node's value. No return value. Description: Sets node value for a node with given id.
def DOM_setNodeValue(self, nodeId, value): assert isinstance(value, (str,) ), "Argument 'value' must be of type '['str']'. Received type: '%s'" % type( value) subdom_funcs = self.synchronous_command('DOM.setNodeValue', nodeId=nodeId, value=value) return subdom_funcs
762,312
Function path: DOM.setAttributeValue Domain: DOM Method name: setAttributeValue Parameters: Required arguments: 'nodeId' (type: NodeId) -> Id of the element to set attribute for. 'name' (type: string) -> Attribute name. 'value' (type: string) -> Attribute value. No return value. Description: Sets attribute for an element with given id.
def DOM_setAttributeValue(self, nodeId, name, value): assert isinstance(name, (str,) ), "Argument 'name' must be of type '['str']'. Received type: '%s'" % type( name) assert isinstance(value, (str,) ), "Argument 'value' must be of type '['str']'. Received type: '%s'" % type( value) subdom_funcs = self.synchronous_command('DOM.setAttributeValue', nodeId= nodeId, name=name, value=value) return subdom_funcs
762,313
Function path: DOM.setOuterHTML Domain: DOM Method name: setOuterHTML Parameters: Required arguments: 'nodeId' (type: NodeId) -> Id of the node to set markup for. 'outerHTML' (type: string) -> Outer HTML markup to set. No return value. Description: Sets node HTML markup, returns new node id.
def DOM_setOuterHTML(self, nodeId, outerHTML): assert isinstance(outerHTML, (str,) ), "Argument 'outerHTML' must be of type '['str']'. Received type: '%s'" % type( outerHTML) subdom_funcs = self.synchronous_command('DOM.setOuterHTML', nodeId=nodeId, outerHTML=outerHTML) return subdom_funcs
762,315
Function path: DOM.discardSearchResults Domain: DOM Method name: discardSearchResults WARNING: This function is marked 'Experimental'! Parameters: Required arguments: 'searchId' (type: string) -> Unique search session identifier. No return value. Description: Discards search results from the session with the given id. <code>getSearchResults</code> should no longer be called for that search.
def DOM_discardSearchResults(self, searchId): assert isinstance(searchId, (str,) ), "Argument 'searchId' must be of type '['str']'. Received type: '%s'" % type( searchId) subdom_funcs = self.synchronous_command('DOM.discardSearchResults', searchId=searchId) return subdom_funcs
762,317
Function path: DOM.pushNodeByPathToFrontend Domain: DOM Method name: pushNodeByPathToFrontend WARNING: This function is marked 'Experimental'! Parameters: Required arguments: 'path' (type: string) -> Path to node in the proprietary format. Returns: 'nodeId' (type: NodeId) -> Id of the node for given path. Description: Requests that the node is sent to the caller given its path. // FIXME, use XPath
def DOM_pushNodeByPathToFrontend(self, path): assert isinstance(path, (str,) ), "Argument 'path' must be of type '['str']'. Received type: '%s'" % type( path) subdom_funcs = self.synchronous_command('DOM.pushNodeByPathToFrontend', path=path) return subdom_funcs
762,318
Function path: CSS.setStyleSheetText Domain: CSS Method name: setStyleSheetText Parameters: Required arguments: 'styleSheetId' (type: StyleSheetId) -> No description 'text' (type: string) -> No description Returns: 'sourceMapURL' (type: string) -> URL of source map associated with script (if any). Description: Sets the new stylesheet text.
def CSS_setStyleSheetText(self, styleSheetId, text): assert isinstance(text, (str,) ), "Argument 'text' must be of type '['str']'. Received type: '%s'" % type( text) subdom_funcs = self.synchronous_command('CSS.setStyleSheetText', styleSheetId=styleSheetId, text=text) return subdom_funcs
762,324
Function path: CSS.setRuleSelector Domain: CSS Method name: setRuleSelector Parameters: Required arguments: 'styleSheetId' (type: StyleSheetId) -> No description 'range' (type: SourceRange) -> No description 'selector' (type: string) -> No description Returns: 'selectorList' (type: SelectorList) -> The resulting selector list after modification. Description: Modifies the rule selector.
def CSS_setRuleSelector(self, styleSheetId, range, selector): assert isinstance(selector, (str,) ), "Argument 'selector' must be of type '['str']'. Received type: '%s'" % type( selector) subdom_funcs = self.synchronous_command('CSS.setRuleSelector', styleSheetId=styleSheetId, range=range, selector=selector) return subdom_funcs
762,325
Function path: CSS.setKeyframeKey Domain: CSS Method name: setKeyframeKey Parameters: Required arguments: 'styleSheetId' (type: StyleSheetId) -> No description 'range' (type: SourceRange) -> No description 'keyText' (type: string) -> No description Returns: 'keyText' (type: Value) -> The resulting key text after modification. Description: Modifies the keyframe rule key text.
def CSS_setKeyframeKey(self, styleSheetId, range, keyText): assert isinstance(keyText, (str,) ), "Argument 'keyText' must be of type '['str']'. Received type: '%s'" % type( keyText) subdom_funcs = self.synchronous_command('CSS.setKeyframeKey', styleSheetId=styleSheetId, range=range, keyText=keyText) return subdom_funcs
762,326
Function path: CSS.setStyleTexts Domain: CSS Method name: setStyleTexts Parameters: Required arguments: 'edits' (type: array) -> No description Returns: 'styles' (type: array) -> The resulting styles after modification. Description: Applies specified style edits one after another in the given order.
def CSS_setStyleTexts(self, edits): assert isinstance(edits, (list, tuple) ), "Argument 'edits' must be of type '['list', 'tuple']'. Received type: '%s'" % type( edits) subdom_funcs = self.synchronous_command('CSS.setStyleTexts', edits=edits) return subdom_funcs
762,327
Function path: CSS.setMediaText Domain: CSS Method name: setMediaText Parameters: Required arguments: 'styleSheetId' (type: StyleSheetId) -> No description 'range' (type: SourceRange) -> No description 'text' (type: string) -> No description Returns: 'media' (type: CSSMedia) -> The resulting CSS media rule after modification. Description: Modifies the rule selector.
def CSS_setMediaText(self, styleSheetId, range, text): assert isinstance(text, (str,) ), "Argument 'text' must be of type '['str']'. Received type: '%s'" % type( text) subdom_funcs = self.synchronous_command('CSS.setMediaText', styleSheetId= styleSheetId, range=range, text=text) return subdom_funcs
762,328
Function path: CSS.forcePseudoState Domain: CSS Method name: forcePseudoState Parameters: Required arguments: 'nodeId' (type: DOM.NodeId) -> The element id for which to force the pseudo state. 'forcedPseudoClasses' (type: array) -> Element pseudo classes to force when computing the element's style. No return value. Description: Ensures that the given node will have specified pseudo-classes whenever its style is computed by the browser.
def CSS_forcePseudoState(self, nodeId, forcedPseudoClasses): assert isinstance(forcedPseudoClasses, (list, tuple) ), "Argument 'forcedPseudoClasses' must be of type '['list', 'tuple']'. Received type: '%s'" % type( forcedPseudoClasses) subdom_funcs = self.synchronous_command('CSS.forcePseudoState', nodeId= nodeId, forcedPseudoClasses=forcedPseudoClasses) return subdom_funcs
762,330
Function path: DOMDebugger.setDOMBreakpoint Domain: DOMDebugger Method name: setDOMBreakpoint Parameters: Required arguments: 'nodeId' (type: DOM.NodeId) -> Identifier of the node to set breakpoint on. 'type' (type: DOMBreakpointType) -> Type of the operation to stop upon. No return value. Description: Sets breakpoint on particular operation with DOM.
def DOMDebugger_setDOMBreakpoint(self, nodeId, type): subdom_funcs = self.synchronous_command('DOMDebugger.setDOMBreakpoint', nodeId=nodeId, type=type) return subdom_funcs
762,333
Function path: DOMDebugger.removeDOMBreakpoint Domain: DOMDebugger Method name: removeDOMBreakpoint Parameters: Required arguments: 'nodeId' (type: DOM.NodeId) -> Identifier of the node to remove breakpoint from. 'type' (type: DOMBreakpointType) -> Type of the breakpoint to remove. No return value. Description: Removes DOM breakpoint that was set using <code>setDOMBreakpoint</code>.
def DOMDebugger_removeDOMBreakpoint(self, nodeId, type): subdom_funcs = self.synchronous_command('DOMDebugger.removeDOMBreakpoint', nodeId=nodeId, type=type) return subdom_funcs
762,334
Function path: DOMDebugger.setInstrumentationBreakpoint Domain: DOMDebugger Method name: setInstrumentationBreakpoint WARNING: This function is marked 'Experimental'! Parameters: Required arguments: 'eventName' (type: string) -> Instrumentation name to stop on. No return value. Description: Sets breakpoint on particular native event.
def DOMDebugger_setInstrumentationBreakpoint(self, eventName): assert isinstance(eventName, (str,) ), "Argument 'eventName' must be of type '['str']'. Received type: '%s'" % type( eventName) subdom_funcs = self.synchronous_command( 'DOMDebugger.setInstrumentationBreakpoint', eventName=eventName) return subdom_funcs
762,335
Function path: DOMDebugger.removeInstrumentationBreakpoint Domain: DOMDebugger Method name: removeInstrumentationBreakpoint WARNING: This function is marked 'Experimental'! Parameters: Required arguments: 'eventName' (type: string) -> Instrumentation name to stop on. No return value. Description: Removes breakpoint on particular native event.
def DOMDebugger_removeInstrumentationBreakpoint(self, eventName): assert isinstance(eventName, (str,) ), "Argument 'eventName' must be of type '['str']'. Received type: '%s'" % type( eventName) subdom_funcs = self.synchronous_command( 'DOMDebugger.removeInstrumentationBreakpoint', eventName=eventName) return subdom_funcs
762,336
Function path: DOMDebugger.setXHRBreakpoint Domain: DOMDebugger Method name: setXHRBreakpoint Parameters: Required arguments: 'url' (type: string) -> Resource URL substring. All XHRs having this substring in the URL will get stopped upon. No return value. Description: Sets breakpoint on XMLHttpRequest.
def DOMDebugger_setXHRBreakpoint(self, url): assert isinstance(url, (str,) ), "Argument 'url' must be of type '['str']'. Received type: '%s'" % type( url) subdom_funcs = self.synchronous_command('DOMDebugger.setXHRBreakpoint', url=url) return subdom_funcs
762,337
Function path: DOMDebugger.removeXHRBreakpoint Domain: DOMDebugger Method name: removeXHRBreakpoint Parameters: Required arguments: 'url' (type: string) -> Resource URL substring. No return value. Description: Removes breakpoint from XMLHttpRequest.
def DOMDebugger_removeXHRBreakpoint(self, url): assert isinstance(url, (str,) ), "Argument 'url' must be of type '['str']'. Received type: '%s'" % type( url) subdom_funcs = self.synchronous_command('DOMDebugger.removeXHRBreakpoint', url=url) return subdom_funcs
762,338
Function path: Target.setDiscoverTargets Domain: Target Method name: setDiscoverTargets Parameters: Required arguments: 'discover' (type: boolean) -> Whether to discover available targets. No return value. Description: Controls whether to discover available targets and notify via <code>targetCreated/targetInfoChanged/targetDestroyed</code> events.
def Target_setDiscoverTargets(self, discover): assert isinstance(discover, (bool,) ), "Argument 'discover' must be of type '['bool']'. Received type: '%s'" % type( discover) subdom_funcs = self.synchronous_command('Target.setDiscoverTargets', discover=discover) return subdom_funcs
762,339
Function path: Target.setAttachToFrames Domain: Target Method name: setAttachToFrames Parameters: Required arguments: 'value' (type: boolean) -> Whether to attach to frames. No return value.
def Target_setAttachToFrames(self, value): assert isinstance(value, (bool,) ), "Argument 'value' must be of type '['bool']'. Received type: '%s'" % type( value) subdom_funcs = self.synchronous_command('Target.setAttachToFrames', value =value) return subdom_funcs
762,341
Function path: Target.setRemoteLocations Domain: Target Method name: setRemoteLocations Parameters: Required arguments: 'locations' (type: array) -> List of remote locations. No return value. Description: Enables target discovery for the specified locations, when <code>setDiscoverTargets</code> was set to <code>true</code>.
def Target_setRemoteLocations(self, locations): assert isinstance(locations, (list, tuple) ), "Argument 'locations' must be of type '['list', 'tuple']'. Received type: '%s'" % type( locations) subdom_funcs = self.synchronous_command('Target.setRemoteLocations', locations=locations) return subdom_funcs
762,342
Function path: Target.sendMessageToTarget Domain: Target Method name: sendMessageToTarget Parameters: Required arguments: 'message' (type: string) -> No description Optional arguments: 'sessionId' (type: SessionID) -> Identifier of the session. 'targetId' (type: TargetID) -> Deprecated. No return value. Description: Sends protocol message over session with given id.
def Target_sendMessageToTarget(self, message, **kwargs): assert isinstance(message, (str,) ), "Argument 'message' must be of type '['str']'. Received type: '%s'" % type( message) expected = ['sessionId', 'targetId'] passed_keys = list(kwargs.keys()) assert all([(key in expected) for key in passed_keys] ), "Allowed kwargs are ['sessionId', 'targetId']. Passed kwargs: %s" % passed_keys subdom_funcs = self.synchronous_command('Target.sendMessageToTarget', message=message, **kwargs) return subdom_funcs
762,343
Function path: ServiceWorker.unregister Domain: ServiceWorker Method name: unregister Parameters: Required arguments: 'scopeURL' (type: string) -> No description No return value.
def ServiceWorker_unregister(self, scopeURL): assert isinstance(scopeURL, (str,) ), "Argument 'scopeURL' must be of type '['str']'. Received type: '%s'" % type( scopeURL) subdom_funcs = self.synchronous_command('ServiceWorker.unregister', scopeURL=scopeURL) return subdom_funcs
762,344
Function path: ServiceWorker.updateRegistration Domain: ServiceWorker Method name: updateRegistration Parameters: Required arguments: 'scopeURL' (type: string) -> No description No return value.
def ServiceWorker_updateRegistration(self, scopeURL): assert isinstance(scopeURL, (str,) ), "Argument 'scopeURL' must be of type '['str']'. Received type: '%s'" % type( scopeURL) subdom_funcs = self.synchronous_command('ServiceWorker.updateRegistration', scopeURL=scopeURL) return subdom_funcs
762,345
Function path: ServiceWorker.startWorker Domain: ServiceWorker Method name: startWorker Parameters: Required arguments: 'scopeURL' (type: string) -> No description No return value.
def ServiceWorker_startWorker(self, scopeURL): assert isinstance(scopeURL, (str,) ), "Argument 'scopeURL' must be of type '['str']'. Received type: '%s'" % type( scopeURL) subdom_funcs = self.synchronous_command('ServiceWorker.startWorker', scopeURL=scopeURL) return subdom_funcs
762,346
Function path: ServiceWorker.skipWaiting Domain: ServiceWorker Method name: skipWaiting Parameters: Required arguments: 'scopeURL' (type: string) -> No description No return value.
def ServiceWorker_skipWaiting(self, scopeURL): assert isinstance(scopeURL, (str,) ), "Argument 'scopeURL' must be of type '['str']'. Received type: '%s'" % type( scopeURL) subdom_funcs = self.synchronous_command('ServiceWorker.skipWaiting', scopeURL=scopeURL) return subdom_funcs
762,347
Function path: ServiceWorker.stopWorker Domain: ServiceWorker Method name: stopWorker Parameters: Required arguments: 'versionId' (type: string) -> No description No return value.
def ServiceWorker_stopWorker(self, versionId): assert isinstance(versionId, (str,) ), "Argument 'versionId' must be of type '['str']'. Received type: '%s'" % type( versionId) subdom_funcs = self.synchronous_command('ServiceWorker.stopWorker', versionId=versionId) return subdom_funcs
762,348
Function path: ServiceWorker.inspectWorker Domain: ServiceWorker Method name: inspectWorker Parameters: Required arguments: 'versionId' (type: string) -> No description No return value.
def ServiceWorker_inspectWorker(self, versionId): assert isinstance(versionId, (str,) ), "Argument 'versionId' must be of type '['str']'. Received type: '%s'" % type( versionId) subdom_funcs = self.synchronous_command('ServiceWorker.inspectWorker', versionId=versionId) return subdom_funcs
762,349
Function path: ServiceWorker.setForceUpdateOnPageLoad Domain: ServiceWorker Method name: setForceUpdateOnPageLoad Parameters: Required arguments: 'forceUpdateOnPageLoad' (type: boolean) -> No description No return value.
def ServiceWorker_setForceUpdateOnPageLoad(self, forceUpdateOnPageLoad): assert isinstance(forceUpdateOnPageLoad, (bool,) ), "Argument 'forceUpdateOnPageLoad' must be of type '['bool']'. Received type: '%s'" % type( forceUpdateOnPageLoad) subdom_funcs = self.synchronous_command( 'ServiceWorker.setForceUpdateOnPageLoad', forceUpdateOnPageLoad= forceUpdateOnPageLoad) return subdom_funcs
762,350
Function path: ServiceWorker.deliverPushMessage Domain: ServiceWorker Method name: deliverPushMessage Parameters: Required arguments: 'origin' (type: string) -> No description 'registrationId' (type: string) -> No description 'data' (type: string) -> No description No return value.
def ServiceWorker_deliverPushMessage(self, origin, registrationId, data): assert isinstance(origin, (str,) ), "Argument 'origin' must be of type '['str']'. Received type: '%s'" % type( origin) assert isinstance(registrationId, (str,) ), "Argument 'registrationId' must be of type '['str']'. Received type: '%s'" % type( registrationId) assert isinstance(data, (str,) ), "Argument 'data' must be of type '['str']'. Received type: '%s'" % type( data) subdom_funcs = self.synchronous_command('ServiceWorker.deliverPushMessage', origin=origin, registrationId=registrationId, data=data) return subdom_funcs
762,351
Function path: ServiceWorker.dispatchSyncEvent Domain: ServiceWorker Method name: dispatchSyncEvent Parameters: Required arguments: 'origin' (type: string) -> No description 'registrationId' (type: string) -> No description 'tag' (type: string) -> No description 'lastChance' (type: boolean) -> No description No return value.
def ServiceWorker_dispatchSyncEvent(self, origin, registrationId, tag, lastChance): assert isinstance(origin, (str,) ), "Argument 'origin' must be of type '['str']'. Received type: '%s'" % type( origin) assert isinstance(registrationId, (str,) ), "Argument 'registrationId' must be of type '['str']'. Received type: '%s'" % type( registrationId) assert isinstance(tag, (str,) ), "Argument 'tag' must be of type '['str']'. Received type: '%s'" % type( tag) assert isinstance(lastChance, (bool,) ), "Argument 'lastChance' must be of type '['bool']'. Received type: '%s'" % type( lastChance) subdom_funcs = self.synchronous_command('ServiceWorker.dispatchSyncEvent', origin=origin, registrationId=registrationId, tag=tag, lastChance= lastChance) return subdom_funcs
762,352
Function path: Input.setIgnoreInputEvents Domain: Input Method name: setIgnoreInputEvents Parameters: Required arguments: 'ignore' (type: boolean) -> Ignores input events processing when set to true. No return value. Description: Ignores input events (useful while auditing page).
def Input_setIgnoreInputEvents(self, ignore): assert isinstance(ignore, (bool,) ), "Argument 'ignore' must be of type '['bool']'. Received type: '%s'" % type( ignore) subdom_funcs = self.synchronous_command('Input.setIgnoreInputEvents', ignore=ignore) return subdom_funcs
762,353
Function path: LayerTree.loadSnapshot Domain: LayerTree Method name: loadSnapshot Parameters: Required arguments: 'tiles' (type: array) -> An array of tiles composing the snapshot. Returns: 'snapshotId' (type: SnapshotId) -> The id of the snapshot. Description: Returns the snapshot identifier.
def LayerTree_loadSnapshot(self, tiles): assert isinstance(tiles, (list, tuple) ), "Argument 'tiles' must be of type '['list', 'tuple']'. Received type: '%s'" % type( tiles) subdom_funcs = self.synchronous_command('LayerTree.loadSnapshot', tiles=tiles ) return subdom_funcs
762,357
Function path: Tracing.recordClockSyncMarker Domain: Tracing Method name: recordClockSyncMarker Parameters: Required arguments: 'syncId' (type: string) -> The ID of this clock sync marker No return value. Description: Record a clock sync marker in the trace.
def Tracing_recordClockSyncMarker(self, syncId): assert isinstance(syncId, (str,) ), "Argument 'syncId' must be of type '['str']'. Received type: '%s'" % type( syncId) subdom_funcs = self.synchronous_command('Tracing.recordClockSyncMarker', syncId=syncId) return subdom_funcs
762,358
Function path: Animation.setPlaybackRate Domain: Animation Method name: setPlaybackRate Parameters: Required arguments: 'playbackRate' (type: number) -> Playback rate for animations on page No return value. Description: Sets the playback rate of the document timeline.
def Animation_setPlaybackRate(self, playbackRate): assert isinstance(playbackRate, (float, int) ), "Argument 'playbackRate' must be of type '['float', 'int']'. Received type: '%s'" % type( playbackRate) subdom_funcs = self.synchronous_command('Animation.setPlaybackRate', playbackRate=playbackRate) return subdom_funcs
762,359
Function path: Animation.getCurrentTime Domain: Animation Method name: getCurrentTime Parameters: Required arguments: 'id' (type: string) -> Id of animation. Returns: 'currentTime' (type: number) -> Current time of the page. Description: Returns the current time of the an animation.
def Animation_getCurrentTime(self, id): assert isinstance(id, (str,) ), "Argument 'id' must be of type '['str']'. Received type: '%s'" % type( id) subdom_funcs = self.synchronous_command('Animation.getCurrentTime', id=id) return subdom_funcs
762,360
Function path: Animation.setPaused Domain: Animation Method name: setPaused Parameters: Required arguments: 'animations' (type: array) -> Animations to set the pause state of. 'paused' (type: boolean) -> Paused state to set to. No return value. Description: Sets the paused state of a set of animations.
def Animation_setPaused(self, animations, paused): assert isinstance(animations, (list, tuple) ), "Argument 'animations' must be of type '['list', 'tuple']'. Received type: '%s'" % type( animations) assert isinstance(paused, (bool,) ), "Argument 'paused' must be of type '['bool']'. Received type: '%s'" % type( paused) subdom_funcs = self.synchronous_command('Animation.setPaused', animations =animations, paused=paused) return subdom_funcs
762,361
Function path: Animation.setTiming Domain: Animation Method name: setTiming Parameters: Required arguments: 'animationId' (type: string) -> Animation id. 'duration' (type: number) -> Duration of the animation. 'delay' (type: number) -> Delay of the animation. No return value. Description: Sets the timing of an animation node.
def Animation_setTiming(self, animationId, duration, delay): assert isinstance(animationId, (str,) ), "Argument 'animationId' must be of type '['str']'. Received type: '%s'" % type( animationId) assert isinstance(duration, (float, int) ), "Argument 'duration' must be of type '['float', 'int']'. Received type: '%s'" % type( duration) assert isinstance(delay, (float, int) ), "Argument 'delay' must be of type '['float', 'int']'. Received type: '%s'" % type( delay) subdom_funcs = self.synchronous_command('Animation.setTiming', animationId=animationId, duration=duration, delay=delay) return subdom_funcs
762,362
Function path: Animation.seekAnimations Domain: Animation Method name: seekAnimations Parameters: Required arguments: 'animations' (type: array) -> List of animation ids to seek. 'currentTime' (type: number) -> Set the current time of each animation. No return value. Description: Seek a set of animations to a particular time within each animation.
def Animation_seekAnimations(self, animations, currentTime): assert isinstance(animations, (list, tuple) ), "Argument 'animations' must be of type '['list', 'tuple']'. Received type: '%s'" % type( animations) assert isinstance(currentTime, (float, int) ), "Argument 'currentTime' must be of type '['float', 'int']'. Received type: '%s'" % type( currentTime) subdom_funcs = self.synchronous_command('Animation.seekAnimations', animations=animations, currentTime=currentTime) return subdom_funcs
762,363
Function path: Animation.releaseAnimations Domain: Animation Method name: releaseAnimations Parameters: Required arguments: 'animations' (type: array) -> List of animation ids to seek. No return value. Description: Releases a set of animations to no longer be manipulated.
def Animation_releaseAnimations(self, animations): assert isinstance(animations, (list, tuple) ), "Argument 'animations' must be of type '['list', 'tuple']'. Received type: '%s'" % type( animations) subdom_funcs = self.synchronous_command('Animation.releaseAnimations', animations=animations) return subdom_funcs
762,364
Function path: Animation.resolveAnimation Domain: Animation Method name: resolveAnimation Parameters: Required arguments: 'animationId' (type: string) -> Animation id. Returns: 'remoteObject' (type: Runtime.RemoteObject) -> Corresponding remote object. Description: Gets the remote object of the Animation.
def Animation_resolveAnimation(self, animationId): assert isinstance(animationId, (str,) ), "Argument 'animationId' must be of type '['str']'. Received type: '%s'" % type( animationId) subdom_funcs = self.synchronous_command('Animation.resolveAnimation', animationId=animationId) return subdom_funcs
762,365
Function path: Storage.clearDataForOrigin Domain: Storage Method name: clearDataForOrigin Parameters: Required arguments: 'origin' (type: string) -> Security origin. 'storageTypes' (type: string) -> Comma separated origin names. No return value. Description: Clears storage for origin.
def Storage_clearDataForOrigin(self, origin, storageTypes): assert isinstance(origin, (str,) ), "Argument 'origin' must be of type '['str']'. Received type: '%s'" % type( origin) assert isinstance(storageTypes, (str,) ), "Argument 'storageTypes' must be of type '['str']'. Received type: '%s'" % type( storageTypes) subdom_funcs = self.synchronous_command('Storage.clearDataForOrigin', origin=origin, storageTypes=storageTypes) return subdom_funcs
762,366
Function path: Storage.getUsageAndQuota Domain: Storage Method name: getUsageAndQuota Parameters: Required arguments: 'origin' (type: string) -> Security origin. Returns: 'usage' (type: number) -> Storage usage (bytes). 'quota' (type: number) -> Storage quota (bytes). 'usageBreakdown' (type: array) -> Storage usage per type (bytes). Description: Returns usage and quota in bytes.
def Storage_getUsageAndQuota(self, origin): assert isinstance(origin, (str,) ), "Argument 'origin' must be of type '['str']'. Received type: '%s'" % type( origin) subdom_funcs = self.synchronous_command('Storage.getUsageAndQuota', origin=origin) return subdom_funcs
762,367
Function path: Storage.trackCacheStorageForOrigin Domain: Storage Method name: trackCacheStorageForOrigin Parameters: Required arguments: 'origin' (type: string) -> Security origin. No return value. Description: Registers origin to be notified when an update occurs to its cache storage list.
def Storage_trackCacheStorageForOrigin(self, origin): assert isinstance(origin, (str,) ), "Argument 'origin' must be of type '['str']'. Received type: '%s'" % type( origin) subdom_funcs = self.synchronous_command('Storage.trackCacheStorageForOrigin', origin=origin) return subdom_funcs
762,368
Function path: Storage.untrackCacheStorageForOrigin Domain: Storage Method name: untrackCacheStorageForOrigin Parameters: Required arguments: 'origin' (type: string) -> Security origin. No return value. Description: Unregisters origin from receiving notifications for cache storage.
def Storage_untrackCacheStorageForOrigin(self, origin): assert isinstance(origin, (str,) ), "Argument 'origin' must be of type '['str']'. Received type: '%s'" % type( origin) subdom_funcs = self.synchronous_command( 'Storage.untrackCacheStorageForOrigin', origin=origin) return subdom_funcs
762,369
Function path: Log.startViolationsReport Domain: Log Method name: startViolationsReport Parameters: Required arguments: 'config' (type: array) -> Configuration for violations. No return value. Description: start violation reporting.
def Log_startViolationsReport(self, config): assert isinstance(config, (list, tuple) ), "Argument 'config' must be of type '['list', 'tuple']'. Received type: '%s'" % type( config) subdom_funcs = self.synchronous_command('Log.startViolationsReport', config=config) return subdom_funcs
762,370
Function path: Tethering.bind Domain: Tethering Method name: bind Parameters: Required arguments: 'port' (type: integer) -> Port number to bind. No return value. Description: Request browser port binding.
def Tethering_bind(self, port): assert isinstance(port, (int,) ), "Argument 'port' must be of type '['int']'. Received type: '%s'" % type( port) subdom_funcs = self.synchronous_command('Tethering.bind', port=port) return subdom_funcs
762,371
Function path: Tethering.unbind Domain: Tethering Method name: unbind Parameters: Required arguments: 'port' (type: integer) -> Port number to unbind. No return value. Description: Request browser port unbinding.
def Tethering_unbind(self, port): assert isinstance(port, (int,) ), "Argument 'port' must be of type '['int']'. Received type: '%s'" % type( port) subdom_funcs = self.synchronous_command('Tethering.unbind', port=port) return subdom_funcs
762,372
Function path: Browser.setWindowBounds Domain: Browser Method name: setWindowBounds Parameters: Required arguments: 'windowId' (type: WindowID) -> Browser window id. 'bounds' (type: Bounds) -> New window bounds. The 'minimized', 'maximized' and 'fullscreen' states cannot be combined with 'left', 'top', 'width' or 'height'. Leaves unspecified fields unchanged. No return value. Description: Set position and/or size of the browser window.
def Browser_setWindowBounds(self, windowId, bounds): subdom_funcs = self.synchronous_command('Browser.setWindowBounds', windowId=windowId, bounds=bounds) return subdom_funcs
762,373
Function path: Runtime.releaseObjectGroup Domain: Runtime Method name: releaseObjectGroup Parameters: Required arguments: 'objectGroup' (type: string) -> Symbolic object group name. No return value. Description: Releases all remote objects that belong to a given group.
def Runtime_releaseObjectGroup(self, objectGroup): assert isinstance(objectGroup, (str,) ), "Argument 'objectGroup' must be of type '['str']'. Received type: '%s'" % type( objectGroup) subdom_funcs = self.synchronous_command('Runtime.releaseObjectGroup', objectGroup=objectGroup) return subdom_funcs
762,376
Function path: Runtime.setCustomObjectFormatterEnabled Domain: Runtime Method name: setCustomObjectFormatterEnabled WARNING: This function is marked 'Experimental'! Parameters: Required arguments: 'enabled' (type: boolean) -> No description No return value.
def Runtime_setCustomObjectFormatterEnabled(self, enabled): assert isinstance(enabled, (bool,) ), "Argument 'enabled' must be of type '['bool']'. Received type: '%s'" % type( enabled) subdom_funcs = self.synchronous_command( 'Runtime.setCustomObjectFormatterEnabled', enabled=enabled) return subdom_funcs
762,377
Function path: Debugger.setBreakpointsActive Domain: Debugger Method name: setBreakpointsActive Parameters: Required arguments: 'active' (type: boolean) -> New value for breakpoints active state. No return value. Description: Activates / deactivates all breakpoints on the page.
def Debugger_setBreakpointsActive(self, active): assert isinstance(active, (bool,) ), "Argument 'active' must be of type '['bool']'. Received type: '%s'" % type( active) subdom_funcs = self.synchronous_command('Debugger.setBreakpointsActive', active=active) return subdom_funcs
762,380
Function path: Debugger.setSkipAllPauses Domain: Debugger Method name: setSkipAllPauses Parameters: Required arguments: 'skip' (type: boolean) -> New value for skip pauses state. No return value. Description: Makes page not interrupt on any pauses (breakpoint, exception, dom exception etc).
def Debugger_setSkipAllPauses(self, skip): assert isinstance(skip, (bool,) ), "Argument 'skip' must be of type '['bool']'. Received type: '%s'" % type( skip) subdom_funcs = self.synchronous_command('Debugger.setSkipAllPauses', skip =skip) return subdom_funcs
762,381
Function path: Debugger.setPauseOnExceptions Domain: Debugger Method name: setPauseOnExceptions Parameters: Required arguments: 'state' (type: string) -> Pause on exceptions mode. No return value. Description: Defines pause on exceptions state. Can be set to stop on all exceptions, uncaught exceptions or no exceptions. Initial pause on exceptions state is <code>none</code>.
def Debugger_setPauseOnExceptions(self, state): assert isinstance(state, (str,) ), "Argument 'state' must be of type '['str']'. Received type: '%s'" % type( state) subdom_funcs = self.synchronous_command('Debugger.setPauseOnExceptions', state=state) return subdom_funcs
762,383
Function path: Debugger.setAsyncCallStackDepth Domain: Debugger Method name: setAsyncCallStackDepth Parameters: Required arguments: 'maxDepth' (type: integer) -> Maximum depth of async call stacks. Setting to <code>0</code> will effectively disable collecting async call stacks (default). No return value. Description: Enables or disables async call stacks tracking.
def Debugger_setAsyncCallStackDepth(self, maxDepth): assert isinstance(maxDepth, (int,) ), "Argument 'maxDepth' must be of type '['int']'. Received type: '%s'" % type( maxDepth) subdom_funcs = self.synchronous_command('Debugger.setAsyncCallStackDepth', maxDepth=maxDepth) return subdom_funcs
762,385
Function path: Profiler.setSamplingInterval Domain: Profiler Method name: setSamplingInterval Parameters: Required arguments: 'interval' (type: integer) -> New sampling interval in microseconds. No return value. Description: Changes CPU profiler sampling interval. Must be called before CPU profiles recording started.
def Profiler_setSamplingInterval(self, interval): assert isinstance(interval, (int,) ), "Argument 'interval' must be of type '['int']'. Received type: '%s'" % type( interval) subdom_funcs = self.synchronous_command('Profiler.setSamplingInterval', interval=interval) return subdom_funcs
762,388
Perform the actual serialization. Args: value: the image to transform Returns: a url pointing at a scaled and cached image
def to_representation(self, value): if not value: return None image = get_thumbnail(value, self.geometry_string, **self.options) try: request = self.context.get('request', None) return request.build_absolute_uri(image.url) except: try: return super(HyperlinkedSorlImageField, self).to_representation(image) except AttributeError: # NOQA return super(HyperlinkedSorlImageField, self).to_native(image.url) # NOQA
762,557
Print if and only if the debug flag is set true in the config.yaml file. Args: args : var args of print arguments.
def print_debug(*args, **kwargs): if WTF_CONFIG_READER.get("debug", False) == True: print(*args, **kwargs)
762,560
Check if resource at URL is fetchable. (by trying to fetch it and checking for 200 status. Args: url (str): Url to check. Returns: Returns a tuple of {True/False, response code}
def check_url(url): request = urllib2.Request(url) try: response = urlopen(request) return True, response.code except urllib2.HTTPError as e: return False, e.code
762,562
Get the current base URL. Args: webdriver: Selenium WebDriver instance. Returns: str - base URL. Usage:: driver.get("http://www.google.com/?q=hello+world") WebUtils.get_base_url(driver) #returns 'http://www.google.com'
def get_base_url(webdriver): current_url = webdriver.current_url try: return re.findall("^[^/]+//[^/$]+", current_url)[0] except: raise RuntimeError( u("Unable to process base url: {0}").format(current_url))
762,563
Check if a web driver if mobile. Args: webdriver (WebDriver): Selenium webdriver.
def is_webdriver_mobile(webdriver): browser = webdriver.capabilities['browserName'] if (browser == u('iPhone') or browser == u('android')): return True else: return False
762,565
Check if a web driver if mobile. Args: webdriver (WebDriver): Selenium webdriver.
def is_webdriver_ios(webdriver): browser = webdriver.capabilities['browserName'] if (browser == u('iPhone') or browser == u('iPad')): return True else: return False
762,566
Utility method for switching between windows. It will search through currently open windows, then switch to the window matching the provided PageObject class. Args: page_class (PageObject): Page class to search for/instantiate. webdriver (WebDriver): Selenium webdriver. Usage:: WebUtils.switch_to_window(DetailsPopUpPage, driver) # switches to the pop up window.
def switch_to_window(page_class, webdriver): window_list = list(webdriver.window_handles) original_window = webdriver.current_window_handle for window_handle in window_list: webdriver.switch_to_window(window_handle) try: return PageFactory.create_page(page_class, webdriver) except: pass webdriver.switch_to_window(original_window) raise WindowNotFoundError( u("Window {0} not found.").format(page_class.__class__.__name__))
762,568
Downloads a URL contents to a tempfile. This is useful for testing downloads. It will download the contents of a URL to a tempfile, which you then can open and use to validate the downloaded contents. Args: url (str) : URL of the contents to download. Kwargs: file_name (str): Name of file. extension (str): Extension to use. Return: str - Returns path to the temp file.
def download_to_tempfile(url, file_name=None, extension=None): if not file_name: file_name = generate_timestamped_string("wtf_temp_file") if extension: file_path = temp_path(file_name + extension) else: ext = "" try: ext = re.search(u"\\.\\w+$", file_name).group(0) except: pass file_path = temp_path(file_name + ext) webFile = urllib.urlopen(url) localFile = open(file_path, 'w') localFile.write(webFile.read()) webFile.close() localFile.close() return file_path
762,575
Class method short cut to call PageFactory on itself. Use it to instantiate this PageObject using a webdriver. Args: webdriver (Webdriver): Instance of Selenium Webdriver. Returns: PageObject Raises: InvalidPageError
def create_page(cls, webdriver=None, **kwargs): if not webdriver: webdriver = WTF_WEBDRIVER_MANAGER.get_driver() return PageFactory.create_page(cls, webdriver=webdriver, **kwargs)
762,577
Attempts to instantiate a page object. Args: page_obj_class (PageObject) - PageObject to instantiate. webdriver (WebDriver) - Selenium webdriver to associate with the PageObject Returns: PageObject - If page object instantiation succeeded. True - If page object instantiation failed, but validation was called. None - If validation did not occur.
def __instantiate_page_object(page_obj_class, webdriver, **kwargs): try: page = page_obj_class(webdriver, **kwargs) return page except InvalidPageError: # This happens when the page fails check. # Means validate was implemented, but the check didn't pass. return True except TypeError: # this happens when it tries to instantiate the original abstract # class, or a PageObject where _validate() was not implemented. return False except Exception as e: # Unexpected exception. raise e
762,579
Waits until document.readyState == Complete (e.g. ready to execute javascript commands) Args: page_object (PageObject) : PageObject class Kwargs: timeout (number) : timeout period
def wait_until_page_ready(page_object, timeout=WTF_TIMEOUT_MANAGER.NORMAL): try: do_until(lambda: page_object.webdriver.execute_script("return document.readyState").lower() == 'complete', timeout) except wait_utils.OperationTimeoutError: raise PageUtilOperationTimeoutError( "Timeout occurred while waiting for page to be ready.")
762,583
Captures a screenshot. Args: webdriver (WebDriver) - Selenium webdriver. file_name (str) - File name to save screenshot as.
def take_screenshot(webdriver, file_name): folder_location = os.path.join(ProjectUtils.get_project_root(), WebScreenShotUtil.SCREEN_SHOT_LOCATION) WebScreenShotUtil.__capture_screenshot( webdriver, folder_location, file_name + ".png")
762,603
Captures a screenshot as a reference screenshot. Args: webdriver (WebDriver) - Selenium webdriver. file_name (str) - File name to save screenshot as.
def take_reference_screenshot(webdriver, file_name): folder_location = os.path.join(ProjectUtils.get_project_root(), WebScreenShotUtil.REFERENCE_SCREEN_SHOT_LOCATION) WebScreenShotUtil.__capture_screenshot( webdriver, folder_location, file_name + ".png")
762,604
Constructor Args: server_address (str): Email Server address. username (str): Username password (str): Password
def __init__(self, server_address, username, password): _wtflog.info( "connecting to %s, using %s:%s", server_address, username, password) self._mail = imaplib.IMAP4_SSL(server_address) self._mail.login(username, password) _wtflog.info("connected.")
762,614
Searches for Email by Subject. Returns True or False. Args: subject (str): Subject to search for. Kwargs: match_recipient (str) : Recipient to match exactly. (don't care if not specified) Returns: True - email found, False - email not found
def check_email_exists_by_subject(self, subject, match_recipient=None): # Select inbox to fetch the latest mail on server. self._mail.select("inbox") try: matches = self.__search_email_by_subject(subject, match_recipient) if len(matches) <= 0: return False else: return True except Exception as e: raise e
762,615
Searches for Email by Subject. Returns email's imap message IDs as a list if matching subjects is found. Args: subject (str) - Subject to search for. Kwargs: limit (int) - Limit search to X number of matches, default 50 match_recipient (str) - Recipient to exactly (don't care if not specified) Returns: list - List of Integers representing imap message UIDs.
def find_emails_by_subject(self, subject, limit=50, match_recipient=None): # Select inbox to fetch the latest mail on server. self._mail.select("inbox") matching_uids = self.__search_email_by_subject( subject, match_recipient) return matching_uids
762,616
Fetch contents of email. Args: message_uid (int): IMAP Message UID number. Kwargs: message_type: Can be 'text' or 'html'
def get_email_message(self, message_uid, message_type="text/plain"): self._mail.select("inbox") result = self._mail.uid('fetch', message_uid, "(RFC822)") msg = email.message_from_string(result[1][0][1]) try: # Try to handle as multipart message first. for part in msg.walk(): if part.get_content_type() == message_type: return part.get_payload(decode=True) except: # handle as plain text email return msg.get_payload(decode=True)
762,617
Find the a set of emails matching each regular expression passed in against the (RFC822) content. Args: *args: list of regular expressions. Kwargs: limit (int) - Limit to how many of the most resent emails to search through. date (datetime) - If specified, it will filter avoid checking messages older than this date.
def raw_search(self, *args, **kwargs): limit = 50 try: limit = kwargs['limit'] except KeyError: pass # Get first X messages. self._mail.select("inbox") # apply date filter. try: date = kwargs['date'] date_str = date.strftime("%d-%b-%Y") _, email_ids = self._mail.search(None, '(SINCE "%s")' % date_str) except KeyError: _, email_ids = self._mail.search(None, 'ALL') # Above call returns email IDs as an array containing 1 str email_ids = email_ids[0].split() matching_uids = [] for _ in range(1, min(limit, len(email_ids))): email_id = email_ids.pop() rfc_body = self._mail.fetch(email_id, "(RFC822)")[1][0][1] match = True for expr in args: if re.search(expr, rfc_body) is None: match = False break if match: uid = re.search( "UID\\D*(\\d+)\\D*", self._mail.fetch(email_id, 'UID')[1][0]).group(1) matching_uids.append(uid) return matching_uids
762,618
Gets the value from the yaml config based on the key. No type casting is performed, any type casting should be performed by the caller. Args: key (str) - Config setting key. Kwargs: default_value - Default value to return if config is not specified. Returns: Returns value stored in config file.
def get(self, key, default_value=__NoDefaultSpecified__): # First attempt to get the var from OS enviornment. os_env_string = ConfigReader.ENV_PREFIX + key os_env_string = os_env_string.replace(".", "_") if type(os.getenv(os_env_string)) != NoneType: return os.getenv(os_env_string) # Otherwise search through config files. for data_map in self._dataMaps: try: if "." in key: # this is a multi levl string namespaces = key.split(".") temp_var = data_map for name in namespaces: temp_var = temp_var[name] return temp_var else: value = data_map[key] return value except (AttributeError, TypeError, KeyError): pass if default_value == self.__NoDefaultSpecified__: raise KeyError(u("Key '{0}' does not exist").format(key)) else: return default_value
762,622
Constructor Args: config_reader (ConfigReader) - override default config reader.
def __init__(self, config_reader=None): if config_reader: self._config = config_reader else: self._config = WTF_CONFIG_READER
762,624
Get data path. Args: filename (string) : Name of file inside of /data folder to retrieve. Kwargs: env_prefix (string) : Name of subfolder, ex: 'qa' will find files in /data/qa Returns: String - path to file. Usage:: open(WTF_DATA_MANAGER.get_data_path('testdata.csv') Note: WTF_DATA_MANAGER is a provided global instance of DataManager
def get_data_path(self, filename, env_prefix=None): if env_prefix == None: target_file = filename else: target_file = os.path.join(env_prefix, filename) if os.path.exists(os.path.join(self._data_path, target_file)): return os.path.join(self._data_path, target_file) else: raise DataNotFoundError( u("Cannot find data file: {0}").format(target_file))
762,630
Constructor Args: file_path (string) : path of CSV file to read.
def __init__(self, file_path): self._file = open(file_path, 'rb') self._csv_reader = csv.reader( self._file, delimiter=',', dialect='excel') self._headers = self._csv_reader.next()
762,631
Wait for a WebElement to disappear. Args: webdriver (Webdriver) - Selenium Webdriver locator (lambda) - Locator lambda expression. Kwargs: timeout (number) - timeout period sleep (number) - sleep period between intervals.
def wait_until_element_not_visible(webdriver, locator_lambda_expression, timeout=WTF_TIMEOUT_MANAGER.NORMAL, sleep=0.5): # Wait for loading progress indicator to go away. try: stoptime = datetime.now() + timedelta(seconds=timeout) while datetime.now() < stoptime: element = WebDriverWait(webdriver, WTF_TIMEOUT_MANAGER.BRIEF).until( locator_lambda_expression) if element.is_displayed(): time.sleep(sleep) else: break except TimeoutException: pass
762,635
Check if an image (in an image tag) is loaded. Note: This call will not work against background images. Only Images in <img> tags. Args: webelement (WebElement) - WebDriver web element to validate.
def is_image_loaded(webdriver, webelement): script = (u("return arguments[0].complete && type of arguments[0].naturalWidth != \"undefined\" ") + u("&& arguments[0].naturalWidth > 0")) try: return webdriver.execute_script(script, webelement) except: return False
762,636
Convert the color from RGB coordinates to HSL. Parameters: :r: The Red component value [0...1] :g: The Green component value [0...1] :b: The Blue component value [0...1] Returns: The color as an (h, s, l) tuple in the range: h[0...360], s[0...1], l[0...1] >>> rgb_to_hsl(1, 0.5, 0) (30.0, 1.0, 0.5)
def rgb_to_hsl(r, g=None, b=None): if type(r) in [list,tuple]: r, g, b = r minVal = min(r, g, b) # min RGB value maxVal = max(r, g, b) # max RGB value l = (maxVal + minVal) / 2.0 if minVal==maxVal: return (0.0, 0.0, l) # achromatic (gray) d = maxVal - minVal # delta RGB value if l < 0.5: s = d / (maxVal + minVal) else: s = d / (2.0 - maxVal - minVal) dr, dg, db = [(maxVal-val) / d for val in (r, g, b)] if r==maxVal: h = db - dg elif g==maxVal: h = 2.0 + dr - db else: h = 4.0 + dg - dr h = (h*60.0) % 360.0 return (h, s, l)
762,671
Convert the color from HSL coordinates to RGB. Parameters: :h: The Hue component value [0...1] :s: The Saturation component value [0...1] :l: The Lightness component value [0...1] Returns: The color as an (r, g, b) tuple in the range: r[0...1], g[0...1], b[0...1] >>> hsl_to_rgb(30.0, 1.0, 0.5) (1.0, 0.5, 0.0)
def hsl_to_rgb(h, s=None, l=None): if type(h) in [list,tuple]: h, s, l = h if s==0: return (l, l, l) # achromatic (gray) if l<0.5: n2 = l * (1.0 + s) else: n2 = l+s - (l*s) n1 = (2.0 * l) - n2 h /= 60.0 hueToRgb = _hue_to_rgb r = hueToRgb(n1, n2, h + 2) g = hueToRgb(n1, n2, h) b = hueToRgb(n1, n2, h - 2) return (r, g, b)
762,673
Convert the color from RGB coordinates to HSV. Parameters: :r: The Red component value [0...1] :g: The Green component value [0...1] :b: The Blue component value [0...1] Returns: The color as an (h, s, v) tuple in the range: h[0...360], s[0...1], v[0...1] >>> rgb_to_hsv(1, 0.5, 0) (30.0, 1.0, 1.0)
def rgb_to_hsv(r, g=None, b=None): if type(r) in [list,tuple]: r, g, b = r v = float(max(r, g, b)) d = v - min(r, g, b) if d==0: return (0.0, 0.0, v) s = d / v dr, dg, db = [(v - val) / d for val in (r, g, b)] if r==v: h = db - dg # between yellow & magenta elif g==v: h = 2.0 + dr - db # between cyan & yellow else: # b==v h = 4.0 + dg - dr # between magenta & cyan h = (h*60.0) % 360.0 return (h, s, v)
762,674
Convert the color from RGB coordinates to HSV. Parameters: :h: The Hus component value [0...1] :s: The Saturation component value [0...1] :v: The Value component [0...1] Returns: The color as an (r, g, b) tuple in the range: r[0...1], g[0...1], b[0...1] >>> hsv_to_rgb(30.0, 1.0, 0.5) (0.5, 0.25, 0.0)
def hsv_to_rgb(h, s=None, v=None): if type(h) in [list,tuple]: h, s, v = h if s==0: return (v, v, v) # achromatic (gray) h /= 60.0 h = h % 6.0 i = int(h) f = h - i if not(i&1): f = 1-f # if i is even m = v * (1.0 - s) n = v * (1.0 - (s * f)) if i==0: return (v, n, m) if i==1: return (n, v, m) if i==2: return (m, v, n) if i==3: return (m, n, v) if i==4: return (n, m, v) return (v, m, n)
762,675
Convert the color from RGB to YIQ. Parameters: :r: The Red component value [0...1] :g: The Green component value [0...1] :b: The Blue component value [0...1] Returns: The color as an (y, i, q) tuple in the range: y[0...1], i[0...1], q[0...1] >>> '(%g, %g, %g)' % rgb_to_yiq(1, 0.5, 0) '(0.592263, 0.458874, -0.0499818)'
def rgb_to_yiq(r, g=None, b=None): if type(r) in [list,tuple]: r, g, b = r y = (r * 0.29895808) + (g * 0.58660979) + (b *0.11443213) i = (r * 0.59590296) - (g * 0.27405705) - (b *0.32184591) q = (r * 0.21133576) - (g * 0.52263517) + (b *0.31129940) return (y, i, q)
762,676
Convert the color from YIQ coordinates to RGB. Parameters: :y: Tte Y component value [0...1] :i: The I component value [0...1] :q: The Q component value [0...1] Returns: The color as an (r, g, b) tuple in the range: r[0...1], g[0...1], b[0...1] >>> '({}, {}, {})'.format(*[round(v, 6) for v in yiq_to_rgb(0.592263, 0.458874, -0.0499818)]) '(1.0, 0.5, 1e-06)'
def yiq_to_rgb(y, i=None, q=None): if type(y) in [list,tuple]: y, i, q = y r = y + (i * 0.9562) + (q * 0.6210) g = y - (i * 0.2717) - (q * 0.6485) b = y - (i * 1.1053) + (q * 1.7020) return (r, g, b)
762,677
Convert the color from RGB coordinates to YUV. Parameters: :r: The Red component value [0...1] :g: The Green component value [0...1] :b: The Blue component value [0...1] Returns: The color as an (y, u, v) tuple in the range: y[0...1], u[-0.436...0.436], v[-0.615...0.615] >>> '(%g, %g, %g)' % rgb_to_yuv(1, 0.5, 0) '(0.5925, -0.29156, 0.357505)'
def rgb_to_yuv(r, g=None, b=None): if type(r) in [list,tuple]: r, g, b = r y = (r * 0.29900) + (g * 0.58700) + (b * 0.11400) u = -(r * 0.14713) - (g * 0.28886) + (b * 0.43600) v = (r * 0.61500) - (g * 0.51499) - (b * 0.10001) return (y, u, v)
762,678
Convert the color from YUV coordinates to RGB. Parameters: :y: The Y component value [0...1] :u: The U component value [-0.436...0.436] :v: The V component value [-0.615...0.615] Returns: The color as an (r, g, b) tuple in the range: r[0...1], g[0...1], b[0...1] >>> '(%g, %g, %g)' % yuv_to_rgb(0.5925, -0.2916, 0.3575) '(0.999989, 0.500015, -6.3276e-05)'
def yuv_to_rgb(y, u=None, v=None): if type(y) in [list,tuple]: y, u, v = y r = y + (v * 1.13983) g = y - (u * 0.39465) - (v * 0.58060) b = y + (u * 2.03211) return (r, g, b)
762,679