Example #1
0
 def get_element_appium(self, timeout=20):
     try:
         return WebDriverWait(self.context.browser, timeout).until(
             ec.element_to_be_clickable((self.mobileBy, self.seletor)))
     except Exception:
         log.message("Element '" + str(self.name) + "' not found")
         raise
Example #2
0
def search_item(context, item):
    try:
        log.message("Searching for: '" + item + "'")
        samplepage.search(item)
    except Exception:
        log.message("Unable to complete the tests step:")
        raise
Example #3
0
 def wait_for_visible_and_click(self, timeout=20):
     try:
         element = WebDriverWait(self.context.browser, timeout).until(ec.element_to_be_clickable((self.by, self.seletor)))
         element.click()
     except Exception:
         log.message("After '" + str(timeout) + "' secconds the element '" + self.name + "' was not displayed")
         raise
Example #4
0
 def wait_for_text(self, expected_text, attempts = 5):
     attempt = 0
     while attempt < attempts:
         if self.get_text() ==  expected_text:
             break
         else:
             attempt = attempt + 1
             log.message("Waiting for text '" + expected_text + "' attempt '" + str(attempt) + "' of '" + str(attempts) + "'")
             time.sleep(3)
Example #5
0
def search_item(context, item):
    try:
        log.message("Checking the results")
        utils.take_screenshot("SearchResult")
        samplepage.spanTitle.seletor = samplepage.spanTitle.seletor % (item)
        samplepage.spanTitle.is_visible()
    except Exception:
        log.message("Unable to complete the tests step:")
        raise
Example #6
0
def app_login(context):
    log.message("Performing login")
    try:
        if len(context.browser.find_elements_by_xpath("//*[@text='OK']")) > 0:
            context.browser.find_element_by_xpath("//*[@text='OK']").click()
        context.browser.find_element_by_xpath(
            "//*[@text='Username']").send_keys('company')
        context.browser.find_element_by_xpath(
            "//*[@text='Password']").send_keys('company')
        context.browser.find_element_by_xpath("//*[@text='Login']").click()
    except Exception:
        log.message("Unable to complete the tests step:")
        raise
Example #7
0
def access_google(context):

    global samplepage
    global utils
    utils = Utils(context)
    samplepage = SamplePage(context)

    log.message("Acessing google")
    try:
        context.browser.get("http://www.google.com")
    except Exception:
        log.message("Unable to complete the tests step:")
        raise
Example #8
0
 def is_enabled(self, fail = True):
     element = self.get_element()
     # noinspection PyBroadException
     try:
         element.is_enabled()
         if fail:
             log.message("[PASSED] '" + self.name + "' was enabled")
         return True
     except Exception:
         if fail:
             log.message("[FAILED] '" + self.name + "' was not enabled")
             raise
         return False
Example #9
0
def run_google_request(context):
    try:
        url = "https://maps.googleapis.com/maps/api/place/nearbysearch/json"
        payload = dict(location='-33.8670,151.1957',
                       radius='500',
                       types='food',
                       name='cruise',
                       key='AIzaSyDf3CAWByILoUJUqgVpRlyJ6yxS9bf5DOA')

        response = APISDK.post(url, payload)
        dtoresponse = json.loads(
            response.content,
            object_hook=lambda d: namedtuple('X', d.keys())(*d.values()))

        # In this print we are accessing the property "lat" from response
        log.message("Lat: " +
                    str(dtoresponse.results[0].geometry.location.lat))
        assert dtoresponse.status == "OK", "The request status is NOT OK. \nCurrent status: '" \
                                     + str(response.__getattribute__('status')) + "'"
    except Exception:
        log.message("Unable to complete the tests step:")
        raise
Example #10
0
 def is_visible(self, fail = True):
     element = self.get_element()
     # noinspection PyBroadException
     try:
         element.is_displayed()
         if fail:
             log.message("[PASSED] '" + self.name + "' was displayed")
         return True
     except Exception as ex:
         if fail:
             log.message(ex)
             log.message("[FAILED] '" + self.name + "' was not displayed")
             raise
         return False
Example #11
0
 def wait_for_visible(self, timeout=20):
     try:
         WebDriverWait(self.context.browser, timeout).until(ec.visibility_of_element_located((self.by, self.seletor)))
     except Exception:
         log.message("After '" + str(timeout) + "' secconds the element '" + self.name + "' was not displayed")
         raise
Example #12
0
 def tap(self):
     element = self.get_element_appium(self.seletor)
     log.message("Clicking at element '" + self.name + "'")
     element.tap()
Example #13
0
 def clickAppium(self, context_view = None):
     self.__check_and_switch_context(context_view)
     element = self.get_element_appium()
     log.message("Clicking at element '" + self.name + "'")
     element.click()
Example #14
0
 def click(self):
     element = self.get_element()
     log.message("Clicking at element '" + self.name + "'")
     element.click()
Example #15
0
 def get_element(self, timeout=20):
     try:
         return WebDriverWait(self.context.browser, timeout).until(ec.presence_of_element_located((self.by, self.seletor)))
     except Exception:
         log.message("Element '" + str(self.name) + "' not found")
         raise
def IsEqual(actual, expected, name, fail = True):
    try:
        assert_equal(actual, expected, "[FAILED] '%s' Expected [%s] Actual [%s]" % (name, expected, actual))
        log.message("[PASSED] '" + name + "' Expected [" + expected + "] Actual [" + actual + "]")
    except AssertionError as ex:
        __treat_failure(fail, ex)
def IsNotEqual(first, second, name, fail = False):
    try:
        assert_not_equal(first, second, "[FAILED] '%s' First [%s] is equal to Second [%s]" % (name, first, second))
        log.message("[PASSED] '" + name + "' Value [" + first + "] is not equal to [ " + second + "]")
    except AssertionError as ex:
        __treat_failure(fail, ex)
def IsNone(object, name, fail = False):
    try:
        assert_is_none(object, "[FAILED] '" + name + "' Expected [None] Actual [" + object + "]")
        log.message("[PASSED] '" + name + "' Expected [None] Actual [None]")
    except AssertionError as ex:
        __treat_failure(fail, ex)
def IsFalse(object, name, fail = False):
    try:
        assert_false(object, "[FAILED] '" + name + "' Expected [False] Actual [True]")
        log.message("[PASSED] '" + name + "' Value is False")
    except AssertionError as ex:
        __treat_failure(fail, ex)
def IsNotIn(container, value, name, fail = False):
    try:
        assert_not_in(value, "[FAILED] '%s' Value [%s] is in [%s]" % (name, value, container))
        log.message("[PASSED] '" + name + "' Value [" + value + "] is not in [" + container + "]")
    except AssertionError as ex:
        __treat_failure(fail, ex)