Package: prodigyqa
Unified QA automation framework!prodigyqais a unified test automation framework based on python. This has come up after thoroughly study made on existing methodologies used in majority of projects for UI/Rest API testing, This is expected to solve a list of problem statements readily.
The framework aims to be a constructive blend of various guidelines, coding standards, concepts, processes, practices, project hierarchies, modularity, reporting mechanism, test data injections etc., to pillar automation testing.Key FeaturesSelenium functions:This module contains a good number of Selenium wrapped functions which are commonly used for UI Testing. These wrapped functions provide a shield of exception handling over the regular selenium methods, handling all different kinds of exception that can occur. If due to some reason, any of the provided method doesnot work, then there is a provision of fall back mechanism, provided in each method, by leveraging additional technologies/javascriptRest API functions:This module contains Rest API wrapped functions which are commonly used for Rest API Testing, by leveraging python 'requests' library. The methods are generalized, to handle any kind of request like GET, PUT, POST, DELETE etc. The module has provison to manage the authentication token. Additionally, there are generic methods for commonly used assertion types and for validating the parameters, that come along with a request like headers, payload etc. in a most possible simplified mannerUtilities:This module aims to provide community backed utility libraries built with a focus on reusability. Following are the utilities, currently supported by the framework:Image Comparison:This module provides provision for image comparison through openCV, SSIM(Structured similarity index) as opposed to pixel by pixel comparison. The methods are generic and need just 2 images to compute the difference.Captcha Reading:This utility performs the captcha reading from an image, by leveraging the 'pytesseract' module. It takes an image as input, containing captcha, and returns a string, mentioning the captcha.Spell Check, Accessibility Check in web application:This module is in WIP mode, where we are enabling spell checks and accessibility checks in web applications, by leveraging the web spider concept, which browses the World Wide Web in a methodical, automated manner, takes out all the links from a web page so that the process could be repeated.Reporting:The framework is flexible enough to work with multiple reporting platforms likereportportal.io,allure-reportetc. A regular, self-contained and customizable HTML report can also be generated through the use ofpytest-htmlmodule.(which is bundled as a dependency for this package)Continuous Testing:The framework provides the facility for CT(Continuous Testing) by leveraging Docker. The docker file provided in the framework can be used to setup the necessary prerequisites/environment, needed to run the framework, on any server, from scratch.PrerequisitesThe framework works withpython 3.5+pippytestto be installed in the machine.InstallingValid/Tested Version is suggested to be installed directly from PyPi as it will solve the issue of dependencies automatically.pip install prodigyqaIn case of any custom updates done to the current setup,we will need to clone the current repository and runpython setup.py developso that the local changes are reflected in the install version.Running the testsThe sample test cases for all the features are listed underprodigyqa --> Examplesfolder. To run the sample tests, open command prompt/terminal, go to prodigyqa --> Examples folder and run the following command:pytest {filename}.py -s(-s indicates the standard output, please referherefor a detailed understanding around pytest framework and its features/plugins/options etc.)Browser ActionsBrowser Actions Module method SummaryThis module wraps around selenium web driver functions.
Below are the major areas handled in this module:Most frequently, a DOM refresh will cause an exception (StaleElementReferenceException) if the object is changing state.  we are handling this by checking Web Page Expected to be in the ready state and Catch the exception to prevent a failure if the object is not present in web page after web page is in the expected state.Most of the functions of this module will Catch the exception to prevent a failure.Method NameDescriptionArgsUsagepage_readiness_waitWeb Page Expected to be in ready state.self.page_readiness_wait()locator_checkLocal Method to classify the type of locator.(a)locator_dict: dictionary of locator value, locator by and valueself.locator_check( locator_dict)openOpen the passed 'url'.self.open(url)reload_pageMethod to refresh the page by selenium or java script.self.reload_page()get_page_sourceReturn the entire HTML source of the current page or frame.self.get_page_source()get_titleReturn the title of current page.self.get_title()get_locationReturn the current browser URL using Selenium/Java Script.self.get_location()get_attributefetch attribute from provided locator/element/parent element with child locator.(a) locator: dictionary of identifier type and value ({'by':'id', 'value':'start-of-content.'}). (b) attribute_name: attribute name to get it's value . (c) element: it is a webelement . (d) type : the type value should be 'locator' or 'element' or 'mixed'self.get_attribute(locator=None, element=None, attribute_name=None, type='locator')clickClick an element.(a) locator: dictionary of identifier type and value ({'by':'id', 'value':'start-of-content.'}).self.click(locator)send_keysSend text but does not clear the existing text.(a) locator: dictionary of identifier type and value ({'by':'id', 'value':'start-of-content.'}). (b) string to send.self.send_keys(locator)get_textGet text from provided Locator.(a) locator: dictionary of identifier type and value ({'by':'id', 'value':'start-of-content.'}).self.get_text(locator)go_backSimulate back button on browser using selenium or js.self.go_back()go_forwardSimulate forward button on browser using  selenium or js.self.go_forward()set_window_sizeSet width and height of the current window. (window.resizeTo)(a) width: the width in pixels to set the window to. (b) height: the height in pixels to set the window to.self.set_window_size(800,600)maximizeMaximize the current window.self.maximize()get_driver_nameReturn the name of webdriver instance.self.get_driver_name()get_domain_urlMethod to extract domain url from webdriver itself.self.get_domain_url()clear_textClear the text if it's a text entry element(a) locator: dictionary of identifier type and value ({'by':'id', 'value':'start-of-content.'}).self.clear_text(locator)capture_screenshotSave screenshot to the directory(existing or new one).(a) filepath: file name with directory path(C:/images/image.png).self.capture_screenshot(self, filepath)switch_to_active_elementReturn the element with focus, or BODY if nothing has focus.self.switch_to_active_element()switch_to_windowSwitch focus to the specified window using selenium/javascript.(a) name of the window to switchself.switch_to_window(window)switch_to_frameSwitch focus to the specified frame using selenium/javascript.(a) framename: name of the frame to switch.self.switch_to_frame(framename)switch_to_default_contentSwitch focus to the default frame.self.switch_to_default_content()switch_to_alertSwitch focus to an alert on the page.self.switch_to_alert()hover_on_elementHover on a particular element.(a) locator: dictionary of identifier type and value ({'by':'id', 'value':'start-of-content.'}).self.hover_on_element(locator)hover_on_clickHover & click a particular element.(a) locator: dictionary of identifier type and value ({'by':'id', 'value':'start-of-content.'}).self.hover_on_click(locator)wait_for_elementWait for an element to exist in UI.(a) locator: dictionary of identifier type and value ({'by':'id', 'value':'start-of-content.'}).self.wait_for_element(locator)wait_and_accept_alertWait and accept alert present on the page.self.wait_and_accept_alert()wait_and_reject_alertWait for alert and rejects.self.wait_and_reject_alert()select_option_by_indexSelect the option by index.(a) locator: dictionary of identifier type and value ({'by':'id', 'value':'start-of-content.'}). (b) index: integer value for index.self.select_option_by_index(locator, index)select_option_by_valueSelect the option by using value.(a) locator: dictionary of identifier type and value ({'by':'id', 'value':'start-of-content.'}). (b) value: string value to select option.self.select_option_by_value(locator, value)select_option_by_textSelect the value by using text.(a) locator: dictionary of identifier type and value ({'by':'id', 'value':'start-of-content.'}). (b) text: string value to select option.self.select_option_by_text(locator, text)scroll_to_footerScroll till end of the page.self.scroll_to_footer()scroll_to_elementScroll to a particular element on the page.(a) locator: dictionary of identifier type and value ({'by':'id', 'value':'start-of-content.'}).self.scroll_to_element(locator)javascript_clickPerfom a click using javscript(a) locator: dictionary of identifier type and value ({'by':'id', 'value':'start-of-content.'}).self.java(locator)is_element_displayedReturn boolean value based on the element is displayed  with locator.(a) locator: dictionary of identifier type and value ({'by':'id', 'value':'start-of-content.'}).self.is_element_displayed(locator)is_element_enabledReturn boolean value based on the element is enabled  with locator.(a) locator: dictionary of identifier type and value ({'by':'id', 'value':'start-of-content.'}).self.is_element_enabled(locator)is_element_selectedReturn boolean value based on the element is selected  with locator.(a) locator: dictionary of identifier type and value ({'by':'id', 'value':'start-of-content.'}).self.is_element_selected(locator)switch_to_active_windowSwitch focus to new windowSwitch focus to new window from current windowself.switch_to_active_window()switch_to_frame_by_indexSwitch focus to the specified frame based on indexIndex of the frameself.switch_to_frame_by_index(index)API Test ModuleREST API Module method SummaryMethod NameDescriptionArgsUsageapirequesttriggers rest api request based on the input method and kwargs(a).method: GET/POST/PUT/PATCH/DELETE (b).kwargs: Refer below REST API kwarg section tableself.apirequest(method='GET')assert_in_respCheck whether response data contain input member.(a)resp: response to validate. (b)member: value to check in response. (c)container: response key path in dot format which should starts with 'resp.'. example: resp.data.0.nameself.assert_in_resp(resp, member, container)assert_not_in_respCheck whether response data contain input member.(a)resp: response to validate. (b)member: value to check in response. (c)container: response key path in dot format which should starts with 'resp.'. example: resp.data.0.nameself.assert_not_in_resp(resp, member, container)assert_equal_respCheck whether response data contain input member.(a)resp: response to validate. (b)member: value to check in response. (c)container: response key path in dot format which should starts with 'resp.'. example: resp.data.0.nameself.assert_equal_resp(resp, member, container)assert_not_equal_respCheck whether response data contain input member.(a)resp: response to validate. (b)member: value to check in response. (c)container: response key path in dot format which should starts with 'resp.'. example: resp.data.0.nameself.assert_not_equal_resp(resp, member, container)REST API kwarg sectionArg NameArg typeDescriptionurlstandardAPI request urlparamsoptionalDictionary, list of tuples or bytes to send in the body of the Request.dataoptionalDictionary, list of tuples, bytes, or file-like object to send in the body of the Request.jsonoptionalA JSON serializable Python object to send in the body of the Request.headersoptionalDictionary of HTTP Headers to send with the Request.cookiesoptionalDict or CookieJar object to send with the Request.filesoptionalDictionary of 'name': file-like-objects(or {'name': file-tuple}) for multipart encoding upload. file-tuple can be a 2-tuple ('filename', fileobj), 3-tuple ('filename', fileobj, 'content_type') or a 4-tuple ('filename', fileobj, 'content_type', custom_headers), where 'content-type' is a string defining the content type of the given file and custom_headers a dict-like object containing additional headers to add for the file.authoptionalAuth tuple to enable Basic/Digest/Custom HTTP Auth.timeout (float or tuple)optionalHow many seconds to wait for the server to send data before giving up, as a float, or a (connect timeout, read timeout) tuple.allow_redirects (bool)optionalBoolean. Enable/disable GET/OPTIONS/POST/PUT/PATCH/DELETE/HEAD redirection. Defaults to True.proxiesoptionalDictionary mapping protocol to the URL of the proxy.verifyoptionalEither a boolean, in which case it controls whether we verify the servers TLS certificate, or a string, in which case it must be a path to a CA bundle to use. Defaults to True.streamoptionalif False, the response content will be immediately downloaded.certoptionalif String, path to ssl client cert file (.pem). If Tuple, (cert, key) pair.UtilsSpell checker of utils Module method SummaryThis Spell checker method of utils module will capture web page content and Validate it against the standard dictionary to ensure spell is correct.Method NameDescriptionArgsUsagespell_checkerSpell checker.(a) url: web page url (b) words: list of application specific wordsspell_checker(self, url, words=[])lComparison ModuleModule has a utility methods for comparing various file typeMethod NameDescriptionArgsUsagecompare_imagesCompare images and returns structural similarity over the image. Measure of SSIM is returned between 0-1.0 where 1.0 is the most identical and 0 being completely different.a) source image path.  b)target image path.self.compare_images(source, target)compare_jsonCompare json files and returns dictionary of difference of target compared to source.a) source json.  b)target jsonself.compare_json(source, target)compare_filesCompare two files and return xl of difference(if any). SupportedfFile Types are xls or xlsx csva) Source file Path.  b)target file Path.self.compare_files(source, target)