Пример #1
0
 def compare_product_list_size(self):
     products_on_page = len(
         self.driver.find_elements(*self.PRODUCT_LIST_ELEMENT))
     button_text = self.driver.find_element(
         *self.SHOW_RESULT_BUTTON_TEXT).text
     logger.info("Total products found - %s" % products_on_page)
     return True if str(products_on_page) in button_text else False
Пример #2
0
def report_on_row(row):
    """checks to see if report has been recently run, calls call_report as needed"""
    #logger = logging.getLogger(__name__)

    user = (row[0])
    report = (row[1])
    last_report_id = (row[2])  #report id of last good run
    run_interval = (row[3])

    if row[4] is not None:  # for first run
        last_run = (row[4]).replace(tzinfo=pytz.utc)
    else:
        last_run = None

    logger.info('Report -  : %s %s %s %s', report, user, last_run,
                datetime.utcnow().replace(tzinfo=pytz.utc))

    if last_run is not None:
        time_since_last_request = datetime.utcnow().replace(
            tzinfo=pytz.utc) - last_run
    else:
        time_since_last_request = None

    if time_since_last_request.total_seconds() > run_interval * 60:
        # check number of mins in db to see if report you want to request has a recent report less then run interval old
        #logger.info("It has been long enough to try and request a new report \n")
        #call_report(report, user)
        t1.add(
            report, user, last_report_id
        )  # report you would like to ask for plus id of last good run as some reports are built
Пример #3
0
 def get_element(self, locator, condition):
     result = None
     if condition == "clickable":
         result = self.wait.until(EC.element_to_be_clickable(locator))
     elif condition == "visibility":
         logger.info("Wait for element [%s] visibility" % str(locator))
         result = self.wait.until(EC.visibility_of_element_located(locator))
     elif condition == "invisibility":
         logger.info("Wait for element [%s] invisibility" % str(locator))
         result = self.wait.until(EC.invisibility_of_element_located(locator))
     return result
Пример #4
0
 def tear_down():
     path = os.path.dirname(__file__)
     abspath = path.split("task", 1)[0]
     testname = request.node.name
     if request.node.rep_call.failed:
         logger.info("Make screenshot when failure")
         '''
         Где 'task' - корневая директория проекта. 
         Сделано это для того, что бы сохранение логов и скринов работало одинаково
         при запуске из различных мест проекта.
         Например из: $../task и $../task/tests или же при помощи ide
         '''
         fixture.driver.save_screenshot("%s/task/reports/screenshots/%sscreenshot_%s.png" % (abspath, time.time(), testname))
Пример #5
0
 def get_last_book_name_on_page(self):
     books = self.driver.find_elements(*self.NOTEBOOK_NAME)
     book_name = books[-1].text
     logger.info("Last notebook name is [%s]" % book_name)
     return book_name
Пример #6
0
 def swith_to_frame(self, frame_locator):
     logger.info("Switch to iframe [%s]" % str(frame_locator))
     self.driver.switch_to.frame(self.driver.find_element(*frame_locator))
Пример #7
0
 def move_to_and_click(self, locator):
     logger.info("Move to and click on [%s]" % str(locator))
     element = self.driver.find_element(*locator)
     self.driver.execute_script("arguments[0].scrollIntoView();", element)
     element.click()
Пример #8
0
 def click(self, locator):
     logger.info("Click on [%s]" % str(locator))
     self.get_element(locator, "clickable").click()