From 1ce38c84a5d91cc846726829fb57829390b95135 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Wed, 4 Mar 2020 05:24:08 +0000 Subject: [PATCH 1/5] Bump ipdb from 0.12.2 to 0.13.2 Bumps [ipdb](https://github.com/gotcha/ipdb) from 0.12.2 to 0.13.2. - [Release notes](https://github.com/gotcha/ipdb/releases) - [Changelog](https://github.com/gotcha/ipdb/blob/master/HISTORY.txt) - [Commits](https://github.com/gotcha/ipdb/compare/0.12.2...0.13.2) Signed-off-by: dependabot-preview[bot] --- requirements.txt | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index fff0a0e..52280d7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -12,7 +12,7 @@ pycodestyle<2.6.0,>=2.5.0 pandas==0.24.2 urllib3==1.25.7 requests>=2.21.0 -ipdb==0.12.2 +ipdb==0.13.2 pytest>=4.0.2 pytest-html<2.1.0 xlrd>=0.9.0 diff --git a/setup.py b/setup.py index 2c9c463..c801233 100644 --- a/setup.py +++ b/setup.py @@ -55,7 +55,7 @@ 'pandas==0.24.2', 'urllib3==1.25.7', 'requests>=2.21.0', - 'ipdb==0.12.2', + 'ipdb==0.13.2', 'pytest>=4.0.2', 'pytest-html<2.1.0', 'xlrd>=0.9.0', From 717f4ccc6f7f98e7587b0c3420eb23a2bff2a94c Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Thu, 12 Mar 2020 05:23:25 +0000 Subject: [PATCH 2/5] Update pytest-html requirement from <2.1.0 to <2.2.0 Updates the requirements on [pytest-html](https://github.com/pytest-dev/pytest-html) to permit the latest version. - [Release notes](https://github.com/pytest-dev/pytest-html/releases) - [Changelog](https://github.com/pytest-dev/pytest-html/blob/master/CHANGES.rst) - [Commits](https://github.com/pytest-dev/pytest-html/compare/1.0...v2.1.0) Signed-off-by: dependabot-preview[bot] --- requirements.txt | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index fff0a0e..07a4a73 100644 --- a/requirements.txt +++ b/requirements.txt @@ -14,7 +14,7 @@ urllib3==1.25.7 requests>=2.21.0 ipdb==0.12.2 pytest>=4.0.2 -pytest-html<2.1.0 +pytest-html<2.2.0 xlrd>=0.9.0 scrapy loguru diff --git a/setup.py b/setup.py index 2c9c463..9b2a2c6 100644 --- a/setup.py +++ b/setup.py @@ -57,7 +57,7 @@ 'requests>=2.21.0', 'ipdb==0.12.2', 'pytest>=4.0.2', - 'pytest-html<2.1.0', + 'pytest-html<2.2.0', 'xlrd>=0.9.0', 'scrapy', 'nltk', From e4f1a98802c8b87b349196c3485794c30041d469 Mon Sep 17 00:00:00 2001 From: Nagarjuna Date: Fri, 27 Mar 2020 13:20:03 +0530 Subject: [PATCH 3/5] Selnium methods changes --- prodigyqa/browseractions.py | 120 +++++++++++++++++++++++++++++++----- 1 file changed, 105 insertions(+), 15 deletions(-) diff --git a/prodigyqa/browseractions.py b/prodigyqa/browseractions.py index c427e00..96b9bb0 100755 --- a/prodigyqa/browseractions.py +++ b/prodigyqa/browseractions.py @@ -214,7 +214,8 @@ def click(self, locator, index=None): """Click an element. :param locator: dictionary of identifier type - and value ({'by':'id', 'value':'start-of-content.'}). + and value ({'by':'id', 'value':'start-of-content.'}) or + webelement. :param index: Defaults None, number/position of element """ self.page_readiness_wait() @@ -231,6 +232,15 @@ def click(self, locator, index=None): self.__find_element(locator).click() elif isinstance(locator, WebElement): locator.click() + elif isinstance(locator, list): + if index is not None: + if index < len(locator): + locator[index].click() + else: + raise AssertionError( + "Index is greater than no. of elements present") + else: + locator[0].click() else: raise AssertionError( "Dictionary/Weblement are valid Locator types.") @@ -260,11 +270,22 @@ def javascript_click(self, locator, index=None): self.by_value, value=locator['locatorvalue'])) elif isinstance(locator, WebElement): self.__execute_script("arguments[0].click();", locator) + elif isinstance(locator, list): + if index is not None: + if index < len(locator): + self.driver.execute_script( + "arguments[0].click();", locator[index]) + else: + raise AssertionError( + "Index is greater than no. of elements present") + else: + self.driver.execute_script( + "arguments[0].click();", locator[0]) else: raise AssertionError( "Locator type should be either dictionary or Weblement.") - def is_element_displayed(self, locator: dict): + def is_element_displayed(self, locator,index=None): """ Check whether an element is diplayed. @@ -272,16 +293,35 @@ def is_element_displayed(self, locator: dict): and value ({'by':'id', 'value':'start-of-content.'}). :type locator: dict """ - self.locator_check(locator) self.page_readiness_wait() if isinstance(locator, dict): - return self.driver.find_element( - self.by_value, - value=locator['locatorvalue']).is_displayed() + self.locator_check(locator) + if index is not None: + web_elts = self.find_elements(locator) + if index < len(web_elts): + return web_elts[index].is_displayed() + else: + raise AssertionError( + "Index is greater than the number of elements") + else: + return self.driver.find_element( + self.by_value, + value=locator['locatorvalue']).is_displayed() + elif isinstance(locator, WebElement): + locator.is_displayed() + elif isinstance(locator, list): + if index is not None: + if index < len(locator): + return locator[index].is_displayed() + else: + raise AssertionError( + "Index is greater than no. of elements present") + else: + return locator[0].is_displayed() else: raise AssertionError("Locator type should be dictionary.") - def is_element_enabled(self, locator: dict): + def is_element_enabled(self, locator): """ Check whether an element is enabled. @@ -293,6 +333,8 @@ def is_element_enabled(self, locator: dict): self.page_readiness_wait() if isinstance(locator, dict): return self.__find_element(locator).is_enabled() + elif isinstance(locator, WebElement): + locator.is_enabled() else: raise AssertionError("Locator type should be dictionary.") @@ -308,6 +350,8 @@ def is_element_selected(self, locator: dict): self.page_readiness_wait() if isinstance(locator, dict): return self.__find_element(locator).is_selected() + elif isinstance(locator, WebElement): + locator.is_selected() else: raise AssertionError("Locator type should be dictionary.") @@ -324,6 +368,8 @@ def send_keys(self, locator: dict, value=None): self.__find_element(locator).send_keys( locator['value'] if value is None else value) + elif isinstance(locator, WebElement): + locator.send_keys(value) else: raise AssertionError("Locator type should be dictionary.") @@ -345,7 +391,6 @@ def get_text(self, locator, index=None): "Index is greater than the number of elements") else: return self.__find_element(locator).text - elif isinstance(locator, WebElement): return locator.text else: @@ -401,7 +446,7 @@ def get_domain_url(self): url = self.driver.current_url return url.split('//')[0] + '//' + url.split('/')[2] - def clear_text(self, locator: dict): + def clear_text(self, locator): """Clear the text if it's a text entry element. :param locator: dictionary of identifier type @@ -412,6 +457,8 @@ def clear_text(self, locator: dict): self.page_readiness_wait() if isinstance(locator, dict): return self.__find_element(locator).clear() + elif isinstance(locator, WebElement): + locator.clear() else: raise AssertionError("Locator type should be dictionary") @@ -454,6 +501,7 @@ def switch_to_window(self, window): except selenium_exceptions.NoSuchWindowException: AssertionError( "Targeted window {} to be switched doesn't exist".window) + "Targeted window {} to be switched doesn't exist".window) def switch_to_active_window(self): """Switch focus to Active window.""" @@ -600,7 +648,7 @@ def select_option_by_index(self, locator: dict, index: int): AssertionError( "Invalid locator '{}' or index '{}'".format(locator, index)) - def select_option_by_value(self, locator: dict, value: int): + def select_option_by_value(self, locator: dict, value): """Select the option by using value. :param locator: dictionary of identifier type @@ -610,16 +658,16 @@ def select_option_by_value(self, locator: dict, value: int): :type value: int """ self.page_readiness_wait() - if isinstance(locator, dict) and isinstance(value, int): + if isinstance(locator, dict): + self.locator_check(locator) try: - Select(self.__find_element(locator)).select_by_value(value) - + Select(self.__find_element(locator) + ).select_by_value(value) except selenium_exceptions.NoSuchElementException: logger.error("Exception : Element '{}' Not Found".format( locator['by'] + '=' + locator['locatorvalue'])) else: - AssertionError( - "Invalid locator '{}' or value '{}'".format(locator, value)) + AssertionError("Invalid locator type") def select_option_by_text(self, locator: dict, text): """Select the value by using text. @@ -641,6 +689,26 @@ def select_option_by_text(self, locator: dict, text): else: AssertionError("Invalid locator type") + def select_option_by_value(self, locator: dict, value): + """Select the option by using value. + + :param locator: dictionary of identifier type + and value ({'by':'id', 'value':'start-of-content.'}). + :param value: string value to select option. + :type locator: dict + :type value: int + """ + self.page_readiness_wait() + if isinstance(locator, dict): + self.locator_check(locator) + try: + Select(self.__find_element(locator) + ).select_by_value(value) + except selenium_exceptions.NoSuchElementException: + logger.error("Exception : Element '{}' Not Found".format( + locator['by'] + '=' + locator['locatorvalue'])) + else: + AssertionError("Invalid locator type") def scroll_to_footer(self): """Scroll till end of the page.""" self.page_readiness_wait() @@ -715,3 +783,25 @@ def __execute_script(self, script, web_elm=None): return self.driver.execute_script( script, self.__find_element(web_elm)) + def getListSize(self,locator: dict): + self.locator_check(locator) + self.page_readiness_wait() + if isinstance(locator,dict): + return len(self.find_elements(locator)) + else: + AssertionError("Invalid locator type") + def geWebElement(self,locator: dict): + self.locator_check(locator) + self.page_readiness_wait() + if isinstance(locator, dict): + return self.__find_element(locator) + else: + AssertionError("Invalid locator type") + + def geWebElement(self,locator: dict): + self.locator_check(locator) + self.page_readiness_wait() + if isinstance(locator, dict): + return self.__find_element(locator) + else: + AssertionError("Invalid locator type") \ No newline at end of file From 6b6e36e6114a7eae03063e757c11c3e4fabb51a2 Mon Sep 17 00:00:00 2001 From: Menta Venkata Surendra Revanth Date: Tue, 31 Mar 2020 00:14:08 +0530 Subject: [PATCH 4/5] MAINT:Flake8 fixes and duplicate methods removed with Doc strings added --- prodigyqa/browseractions.py | 107 +++++++++++++----------------------- 1 file changed, 38 insertions(+), 69 deletions(-) diff --git a/prodigyqa/browseractions.py b/prodigyqa/browseractions.py index 96b9bb0..65453b8 100755 --- a/prodigyqa/browseractions.py +++ b/prodigyqa/browseractions.py @@ -159,12 +159,12 @@ def get_attribute(self, locator=None, element=None, """Fetch attribute from locator/element/parent. element with child locator. - :param locator: dictionary of identifier type + :param locator:dictionary of identifier type and value ({'by':'id', 'value':'start-of-content.'}). :param attribute_name: attribute name to get it's vale :param element: it is a webelement :param type : value can only be 'locator' or 'element' or 'mixed' - :type locator: dict + :type locator:dict :type type: str """ valid_arguments_of_type = ['locator', 'element', 'mixed'] @@ -213,7 +213,7 @@ def get_attribute(self, locator=None, element=None, def click(self, locator, index=None): """Click an element. - :param locator: dictionary of identifier type + :param locator:dictionary of identifier type and value ({'by':'id', 'value':'start-of-content.'}) or webelement. :param index: Defaults None, number/position of element @@ -248,7 +248,7 @@ def click(self, locator, index=None): def javascript_click(self, locator, index=None): """Javascript Click on provided element. - :param locator: dictionary of identifier type + :param locator:dictionary of identifier type and value ({'by':'id', 'value':'start-of-content.'}) or a Webelement. :param index: Number/position of element present @@ -285,13 +285,13 @@ def javascript_click(self, locator, index=None): raise AssertionError( "Locator type should be either dictionary or Weblement.") - def is_element_displayed(self, locator,index=None): + def is_element_displayed(self, locator, index=None): """ Check whether an element is diplayed. - :param locator: dictionary of identifier type + :param locator:dictionary of identifier type and value ({'by':'id', 'value':'start-of-content.'}). - :type locator: dict + :type locator:dict """ self.page_readiness_wait() if isinstance(locator, dict): @@ -325,9 +325,9 @@ def is_element_enabled(self, locator): """ Check whether an element is enabled. - :param locator: dictionary of identifier type + :param locator:dictionary of identifier type and value ({'by':'id', 'value':'start-of-content.'}). - :type locator: dict + :type locator:dict """ self.locator_check(locator) self.page_readiness_wait() @@ -342,9 +342,9 @@ def is_element_selected(self, locator: dict): """ Check whether an element is selecte. - :param locator: dictionary of identifier type + :param locator:dictionary of identifier type and value ({'by':'id', 'value':'start-of-content.'}). - :type locator: dict + :type locator:dict """ self.locator_check(locator) self.page_readiness_wait() @@ -358,9 +358,9 @@ def is_element_selected(self, locator: dict): def send_keys(self, locator: dict, value=None): """Send text but does not clear the existing text. - :param locator: dictionary of identifier type + :param locator:dictionary of identifier type and value ({'by':'id', 'value':'start-of-content.'}). - :type locator: dict + :type locator:dict """ self.page_readiness_wait() if isinstance(locator, dict): @@ -376,7 +376,7 @@ def send_keys(self, locator: dict, value=None): def get_text(self, locator, index=None): """Get text from provided Locator. - :param locator: dictionary of identifier type + :param locator:dictionary of identifier type and value ({'by':'id', 'value':'start-of-content.'}). """ self.page_readiness_wait() @@ -449,9 +449,9 @@ def get_domain_url(self): def clear_text(self, locator): """Clear the text if it's a text entry element. - :param locator: dictionary of identifier type + :param locator:dictionary of identifier type and value ({'by':'id', 'value':'start-of-content.'}). - :type locator: dict + :type locator:dict """ self.locator_check(locator) self.page_readiness_wait() @@ -501,7 +501,6 @@ def switch_to_window(self, window): except selenium_exceptions.NoSuchWindowException: AssertionError( "Targeted window {} to be switched doesn't exist".window) - "Targeted window {} to be switched doesn't exist".window) def switch_to_active_window(self): """Switch focus to Active window.""" @@ -558,9 +557,9 @@ def switch_to_alert(self): def hover_on_element(self, locator: dict): """Hover on a particular element. - :param locator: dictionary of identifier type + :param locator:dictionary of identifier type and value ({'by':'id', 'value':'start-of-content.'}). - :type locator: dict + :type locator:dict """ self.locator_check(locator) self.page_readiness_wait() @@ -578,7 +577,7 @@ def hover_on_element(self, locator: dict): def hover_on_click(self, locator): """Hover & click a particular element. - :param locator: dictionary of identifier type + :param locator:dictionary of identifier type and value ({'by':'id', 'value':'start-of-content.'}). """ self.locator_check(locator) @@ -594,7 +593,7 @@ def hover_on_click(self, locator): def wait_for_element(self, locator) -> bool: """Wait for an element to exist in UI. - :param locator: dictionary of identifier type + :param locator:dictionary of identifier type and value ({'by':'id', 'value':'start-of-content.'}). :rtype: bool """ @@ -630,10 +629,10 @@ def wait_and_reject_alert(self): def select_option_by_index(self, locator: dict, index: int): """Select the option by index. - :param locator: dictionary of identifier type + :param locator:dictionary of identifier type and value ({'by':'id', 'value':'start-of-content.'}). :param index: integer value for index. - :type locator: dict + :type locator:dict :type index: int """ self.by_value = locator['by'] @@ -651,10 +650,10 @@ def select_option_by_index(self, locator: dict, index: int): def select_option_by_value(self, locator: dict, value): """Select the option by using value. - :param locator: dictionary of identifier type + :param locator:dictionary of identifier type and value ({'by':'id', 'value':'start-of-content.'}). :param value: string value to select option. - :type locator: dict + :type locator:dict :type value: int """ self.page_readiness_wait() @@ -672,10 +671,10 @@ def select_option_by_value(self, locator: dict, value): def select_option_by_text(self, locator: dict, text): """Select the value by using text. - :param locator: dictionary of identifier type + :param locator:dictionary of identifier type and value ({'by':'id', 'value':'start-of-content.'}). :param text: string value to select option. - :type locator: dict + :type locator:dict """ self.page_readiness_wait() if isinstance(locator, dict): @@ -689,26 +688,6 @@ def select_option_by_text(self, locator: dict, text): else: AssertionError("Invalid locator type") - def select_option_by_value(self, locator: dict, value): - """Select the option by using value. - - :param locator: dictionary of identifier type - and value ({'by':'id', 'value':'start-of-content.'}). - :param value: string value to select option. - :type locator: dict - :type value: int - """ - self.page_readiness_wait() - if isinstance(locator, dict): - self.locator_check(locator) - try: - Select(self.__find_element(locator) - ).select_by_value(value) - except selenium_exceptions.NoSuchElementException: - logger.error("Exception : Element '{}' Not Found".format( - locator['by'] + '=' + locator['locatorvalue'])) - else: - AssertionError("Invalid locator type") def scroll_to_footer(self): """Scroll till end of the page.""" self.page_readiness_wait() @@ -721,9 +700,9 @@ def scroll_to_footer(self): def find_elements(self, locator: dict): """Return elements matched with locator. - :param locator: dictionary of identifier type + :param locator:dictionary of identifier type and value ({'by':'id', 'value':'start-of-content.'}). - :type locator: dict + :type locator:dict """ self.locator_check(locator) self.page_readiness_wait() @@ -737,9 +716,9 @@ def find_elements(self, locator: dict): def scroll_to_element(self, locator: dict): """Scroll to a particular element on the page. - :param locator: dictionary of identifier type + :param locator:dictionary of identifier type and value ({'by':'id', 'value':'start-of-content.'}). - :type locator: dict + :type locator:dict """ self.page_readiness_wait() if isinstance(locator, dict): @@ -760,7 +739,7 @@ def scroll_to_element(self, locator: dict): def __find_element(self, locator: dict): """Private method simplified finding element. - :type locator: dict + :type locator:dict """ if isinstance(locator, dict): self.locator_check(locator) @@ -783,25 +762,15 @@ def __execute_script(self, script, web_elm=None): return self.driver.execute_script( script, self.__find_element(web_elm)) - def getListSize(self,locator: dict): - self.locator_check(locator) - self.page_readiness_wait() - if isinstance(locator,dict): - return len(self.find_elements(locator)) - else: - AssertionError("Invalid locator type") - def geWebElement(self,locator: dict): - self.locator_check(locator) - self.page_readiness_wait() - if isinstance(locator, dict): - return self.__find_element(locator) - else: - AssertionError("Invalid locator type") - def geWebElement(self,locator: dict): + def get_list_size(self, locator: dict): + """ + Get List Size of provided locator. + :param locator: must contain the valid locator. + """ self.locator_check(locator) self.page_readiness_wait() if isinstance(locator, dict): - return self.__find_element(locator) + return len(self.find_elements(locator)) else: - AssertionError("Invalid locator type") \ No newline at end of file + AssertionError("Invalid locator type") From 52912fee093e5168564a708e920b1e939ccfb1b3 Mon Sep 17 00:00:00 2001 From: Menta Venkata Surendra Revanth Date: Tue, 31 Mar 2020 00:19:50 +0530 Subject: [PATCH 5/5] MAINT:version bump --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index e1dbfc0..5f1336f 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ setup( name='prodigyqa', - version='1.2.2', + version='1.3.0', description='Test Automation Framework', long_description=long_description, long_description_content_type='text/markdown',