Exemplo n.º 1
0
 def add_class(self, locator, class_name):
     logger.info("Add [%s] class to element [%s]" % (locator, class_name))
     time.sleep(
         1.5)  # Wait for execute all jquery requests after click on element
     self.driver.execute_script(
         "return document.querySelector('%s').classList.add('%s')" %
         (locator, class_name))
Exemplo n.º 2
0
 def refresh_page(self):
     logger.info("Refresh page")
     self.driver.refresh()
     while self.is_alert_present():
         self.driver.switch_to.alert.dismiss()
         self.driver.refresh()
         time.sleep(.3)
Exemplo n.º 3
0
 def get_detail(subdomain, email, *, api_key, server):
     student = api.get_student_details(subdomain, email, api_key=api_key, server=server)
     if email in student.values():
         return student
     else:
         logger.info(f"Student with email: {email} not found in subdomain: {subdomain}")
         raise StudentNotFoundException(f"subdomain = {subdomain}, email = {email}")
Exemplo n.º 4
0
 def is_alert_present(self):
     try:
         alert = self.driver.switch_to.alert
         logger.info("Alert is present [%s]" % alert)
         return True
     except NoAlertPresentException:
         logger.info("No alert")
         return False
Exemplo n.º 5
0
 def create(subdomain, email, *args, api_key, server):
     student_detail = subdomain, email, *args
     logger.info(f"Create user on the {subdomain}. \nDetails: {student_detail}")
     try:
         return api.create_student(*student_detail, api_key=api_key, server=server)
     except ReadTimeout:
         logger.info(f"Failed to create student in 10 seconds: {student_detail}")
         raise StudentNotCreatedException(f"Failed to create student in 10 seconds: {student_detail}")
Exemplo n.º 6
0
 def delete_all(subdomain, *, api_key, server):
     logger.info(f"Delete all students from {subdomain}")
     end_time = time.time() + REQUEST_TIME_LIMIT
     while api.get_students_list(subdomain, api_key=api_key, server=server):
         for student in api.get_students_list(subdomain,api_key=api_key, server=server):
             Students().delete_by_email(subdomain, student["email"], api_key=api_key, server=server)
             if time.time() > end_time:
                 logger.info(f"Failed to delete all students in subdomain: {subdomain}")
                 raise TimeoutError(f"Failed to delete all students students:in subdomain: {subdomain}")
Exemplo n.º 7
0
 def remove_all_emails():
     logger.info("Remove all emails")
     box.login(imap_user, imap_pass)
     box.select("Inbox")
     typ, data = box.search(None, "ALL")
     for num in data[0].split():
         box.store(num, "+FLAGS", "\\Deleted")
     box.expunge()
     box.close()
     box.logout()
Exemplo n.º 8
0
 def wait_for_payment_will_done(old_balance):
     end_time = time.time() + REQUEST_TIME_LIMIT
     new_balance = Stripe().get_full_balance()
     while old_balance >= new_balance:
         new_balance = Stripe().get_full_balance()
         if time.time() > end_time:
             logger.info(
                 f"Stripe balance was not changed. Stripe user: {api.get_stripe_info().email}"
             )
             raise TimeoutError(
                 f"Stripe balance was not changed. Stripe user: {api.get_stripe_info().email}"
             )
Exemplo n.º 9
0
    def wait_for_created(subdomain, email, *args, api_key, server):
        end_time = time.time() + REQUEST_TIME_LIMIT

        if args:
            student = api.get_student_details(subdomain, email, api_key=api_key, server=server)
            while True:
                result = [email in student.values()]
                for arg in args:
                    result.append(arg in student.values())
                student = api.get_student_details(subdomain, email, api_key=api_key, server=server)
                if all(result):
                    break
                if time.time() > end_time:
                    logger.info(f"Failed to create student: {email} in subdomain: {subdomain}")
                    raise TimeoutError(f"Failed to create student: subdomain = {subdomain}, email = {email}")
        else:
            student = api.get_student_details(subdomain, email, api_key=api_key, server=server)
            while email not in student.values():
                student = api.get_student_details(subdomain, email, api_key=api_key, server=server)
                if time.time() > end_time:
                    logger.info(f"Failed to create student: {email} in subdomain: {subdomain}")
                    raise TimeoutError(f"Failed to create student: subdomain = {subdomain}, email = {email}")
Exemplo n.º 10
0
 def delete_by_email(subdomain, email, *, api_key, server):
     logger.info(f"Delete user by email: {subdomain}, {email}")
     end_time = time.time() + REQUEST_TIME_LIMIT
     student = api.get_student_details(subdomain, email, api_key=api_key, server=server)
     if email in student.values():
         api.delete_student(subdomain, email, api_key=api_key, server=server)
         while email in student.values():
             student = api.get_student_details(subdomain, email, api_key=api_key, server=server)
             if time.time() > end_time:
                 logger.info(f"Failed to delete student: {email} in subdomain: {subdomain}")
                 raise TimeoutError(f"Failed to delete student: subdomain = {subdomain}, email = {email}")
     else:
         logger.info(f"Student with email: {email} not found in subdomain: {subdomain}")
         raise StudentNotFoundException(f"subdomain = {subdomain}, email = {email}")
Exemplo n.º 11
0
 def switch_tab(self, tab_number):
     logger.info(f"Switch to {tab_number} tab")
     self.driver.switch_to.window(self.driver.window_handles[tab_number])
Exemplo n.º 12
0
 def clear(self):
     logger.info("Clear all storage")
     self.driver.execute_script("window.localStorage.clear();")
Exemplo n.º 13
0
 def scroll_to_top_page(self):
     logger.info("Scroll to top page")
     self.action.send_keys_to_element(
         self.driver.find_element_by_tag_name('body'),
         Keys.CONTROL + Keys.HOME).perform()
Exemplo n.º 14
0
 def get_list(subdomain, *, api_key, server):
     try:
         return api.get_students_list(subdomain, api_key=api_key, server=server)
     except ReadTimeout:
         logger.info(f"Failed to get students list for: {subdomain}")
         raise StudentNotFoundException(f"Failed to get students list for: {subdomain} in 10 seconds")
Exemplo n.º 15
0
 def open(self, url):
     logger.info("Open page: %s" % url)
     self.driver.get(url)
Exemplo n.º 16
0
 def dismiss_alert(self):
     try:
         WebDriverWait(self.driver, 3).until(EC.alert_is_present())
         self.driver.switch_to.alert.dismiss()
     except TimeoutException:
         logger.info("No alert")
Exemplo n.º 17
0
 def switch_to_default_content(self):
     logger.info("Switch to default content")
     self.driver.switch_to.default_content()