def check_login_name(self):
     try:
         timesheet_logger.info(
             "Check Login_Name method Started now waiting for msg to loaded"
         )
         name_from_msg = self.wait.until(
             EC.presence_of_element_located((By.XPATH, name_field))).text
         timesheet_logger.info(
             "Name Captured...now getting loggedin User's Name")
         logged_name = self.wait.until(
             EC.element_to_be_clickable((By.XPATH, login_name))).text
         timesheet_logger.info("Logged User's Name Captured")
         timesheet_logger.info("Now Running formating for captured Data")
         tmp = ''
         for c in logged_name:
             if c == '@':
                 break
             else:
                 tmp = tmp + c
         logged_name = tmp.lower()
         tmp = name_from_msg.split(" ")
         name_from_msg = tmp[3] + '.' + tmp[4]
         if name_from_msg == logged_name:
             timesheet_logger.info("User is Valid {}".format(logged_name))
             return True
         else:
             timesheet_logger.info("Username did not matched")
             return False
     except:
         MyLibrary.save_screenshot_picture(self.driver, 'check_names')
         raise
 def check_task_time(self):
     try:
         timesheet_logger.info("Checking task time for added tasks")
         t1 = datetime(year=2015, day=19, month=1, hour=0, minute=0)
         t2 = t1 + relativedelta(hours=total_hrs, minutes=total_mins)
         t2 = t2.strftime('%H %M')
         worked_time = self.wait.until(
             EC.visibility_of_element_located((By.XPATH, task_time))).text
         worked_time = worked_time.split(" ")[0]
         timesheet_logger.info(
             "Worked time selected and formmated successfully for validation"
         )
         hrs, mins = worked_time.split(":")
         recorded_hrs = int(hrs)
         recorded_mins = int(mins)
         hrs, mins = t2.split(":")
         hrs = int(hrs)
         mins = int(mins)
         if recorded_hrs == hrs and recorded_mins == mins:
             return True
         else:
             return False
     except:
         MyLibrary.save_screenshot_picture(self.driver,
                                           'check_for_task_time')
         raise
 def check_date_for_today(self):
     try:
         timesheet_logger.info(
             "Checking For TimeSheet Opened in Current Date")
         self.wait.until(
             EC.element_to_be_clickable(
                 (By.CLASS_NAME, calender_open_btn))).click()
         timesheet_logger.info("Calender button up-arrow clicked")
         current_date = self.wait.until(
             EC.presence_of_element_located(
                 (By.CLASS_NAME, highlighted_date)))
         timesheet_logger.info("Current date Aquired from calender")
         today = date.today().strftime('%B %d %Y')
         timesheet_logger.info(
             "Getting Todays date from System using datetime package")
         current_date = current_date.get_attribute('aria-label').split(' ')
         timesheet_logger.info("Formatting current date for validations")
         current_date = current_date[1] + ' ' + current_date[
             2] + ' ' + current_date[3]
         timesheet_logger.info("Formatt Successful")
         if today == current_date:
             timesheet_logger.info(
                 "Dates Matched Current Date :: {} Today :: {}".format(
                     current_date, today))
             timesheet_logger.info("TimeSheet Opened in current date")
             return True
         else:
             timesheet_logger.info(
                 "TimeSheet did not opened for Current Date")
             return False
     except:
         MyLibrary.save_screenshot_picture(self.driver,
                                           'check_for_today_date')
         raise
 def enter_username(self, username):
     try:
         field = self.wait.until(
             EC.presence_of_element_located((By.ID, username_field)))
         login_logger.info("UserName field is located")
         field.send_keys(username)
         login_logger.info(
             "Username is sent as input to the username field")
         next_btn = self.wait.until(
             EC.element_to_be_clickable((By.ID, username_nxt_btn)))
         login_logger.info("NextButton is selected")
         next_btn.click()
         login_logger.info("NextButton is Clicked")
         try:
             pass_field = self.wait.until(
                 EC.visibility_of_element_located(
                     (By.NAME, password_field)))
             login_logger.info("Trying to locate password_field")
             return 1
         except:
             login_logger.info(
                 "Failed to locate PassWord field mean Username :: {} entered wrong"
                 .format(username))
             return -1
     except:
         MyLibrary.save_screenshot_picture(self.driver, 'enter_username')
         raise
 def click_big_red_btn(self):
     try:
         self.wait.until(EC.element_to_be_clickable((By.CLASS_NAME, big_red_btn))).click()
         highway_logger.info("Big Red Button Clicked")
     except:
         MyLibrary.save_screenshot_picture(self.driver, 'click_big_red')
         raise
 def open_highway(self, driver):
     try:
         driver.get(highway_site)
         highway_logger.info("Highway HomePage Opened")
     except:
         MyLibrary.save_screenshot_picture(self.driver, 'open_highway')
         raise
 def deleting_entry(self):
     try:
         del_btn = self.wait.until(
             EC.element_to_be_clickable((By.XPATH, delete_btn))).click()
         self.wait.untill(
             EC.invisibility_of_element((By.CLASS_NAME, pop_up)))
         return True
     except:
         MyLibrary.save_screenshot_picture(self.driver, 'delete_entry')
         raise
    def check_add_btn_visible(self):
        try:
            timesheet_logger.info("checking add button visibility")
            add_btn_for_here = self.wait.until(
                EC.visibility_of_element_located((By.CLASS_NAME, status_bar)))
            timesheet_logger.info("add button captured")
            timesheet_logger.info("add_btnss print {}".format(
                add_btn_for_here.get_attribute('disabled')))
            return add_btn_for_here.get_attribute('disabled') == None

        except:
            MyLibrary.save_screenshot_picture(self.driver, 'check_btn_visible')
            raise
 def count_entries(self, driver):
     try:
         timesheet_logger.info("dcounting entries in timetable")
         self.wait = WebDriverWait(driver, 10)
         columns = self.wait.until(
             EC.presence_of_all_elements_located((By.CLASS_NAME, entries)))
         if len(columns) - 1 == entry_count:
             timesheet_logger.info(
                 "Total Entried :: {} ".format(len(columns) - 1))
             return True
         else:
             return False
     except:
         MyLibrary.save_screenshot_picture(driver, 'count_entries')
         raise
 def blue_to_pink(self):
     try:
         timesheet_logger.info("Blue to pink Started...")
         bar = self.wait.until(
             EC.presence_of_element_located((By.CLASS_NAME, status_bar)))
         timesheet_logger.info("color bar element captured")
         color = bar.value_of_css_property('background-color')
         if color == pink:
             timesheet_logger.info("pink colors matched")
             return True
         else:
             timesheet_logger.info("colors matching failed")
             return False
     except:
         MyLibrary.save_screenshot_picture(self.driver, 'blue_to_pink')
         raise
 def next_btn_visible(self):
     try:
         timesheet_logger.info(
             "Checking visibility of"
             " Next Button after TimeSheet Opened for First Time")
         next_btn = self.wait.until(
             EC.presence_of_element_located((By.XPATH, disabled_nxt_btn)))
         timesheet_logger.info("Next Button captured")
         if next_btn.get_attribute('disabled'):
             timesheet_logger.info("NextButton is Disabled")
             return True
         else:
             timesheet_logger.info("NextButton is Enabled")
             return True
     except:
         MyLibrary.save_screenshot_picture(self.driver, 'next_btn_visible')
         raise
 def open_timesheet(self):
     try:
         timesheet_logger.info("Openinng TimeSheet Page")
         self.wait.until(
             EC.element_to_be_clickable(
                 (By.CLASS_NAME, welcome_btn))).click()
         timesheet_logger.info("Welcome btn clicked")
         timesheet_logger.info("Waiting for dashboard to load successfully")
         self.wait.until(
             EC.visibility_of_element_located((By.CLASS_NAME, widget)))
         timesheet_logger.info(
             "DashBoard Loaded....Now clicking on TimeSheet Button")
         self.wait.until(
             EC.element_to_be_clickable((By.XPATH, timesheet_btn))).click()
         timesheet_logger.info("TimeSheet Successfully Opened")
     except:
         MyLibrary.save_screenshot_picture(self.driver, 'open_timesheet')
         raise
 def orange_to_blue(self):
     try:
         timesheet_logger.info("Orange to Blue Started...")
         bar = self.wait.until(
             EC.presence_of_element_located((By.CLASS_NAME, status_bar)))
         timesheet_logger.info("color bar element captured")
         color = bar.value_of_css_property('background-color')
         timesheet_logger.info(
             "BAR COLOR is ::{} Blues suppose to be :: {}".format(
                 color, blue))
         if color == blue:
             timesheet_logger.info("Blue colors matched")
             return True
         else:
             timesheet_logger.info("colors matching failed")
             return False
     except:
         MyLibrary.save_screenshot_picture(self.driver, 'orange_to_blue')
         raise
 def add_entry(self,
               driver,
               proj_value,
               types,
               hrs=1,
               mins=0,
               description=""):
     try:
         timesheet_logger.info("Now Adding an Entry")
         self.wait.until(EC.element_to_be_clickable(
             (By.XPATH, proj_code))).click()
         timesheet_logger.info("project input field clicked")
         option = '//li//span//span[contains(text(),"' + proj_value + '")]'
         self.wait.until(EC.presence_of_element_located(
             (By.XPATH, option))).click()
         timesheet_logger.info("selected an option from project list")
         self.wait.until(EC.element_to_be_clickable(
             (By.XPATH, type_btn))).click()
         timesheet_logger.info("Type Button clicked for options")
         option = '//md-option//div[contains(text(),"' + types + '")]'
         option = self.wait.until(
             EC.visibility_of_element_located((By.XPATH, option))).click()
         timesheet_logger.info("type options selected")
         self.wait.until(EC.element_to_be_clickable(
             (By.NAME, hour_entry))).send_keys(hrs)
         timesheet_logger.info("data sent to hour entry field")
         self.wait.until(EC.element_to_be_clickable(
             (By.NAME, minute_entry))).send_keys(mins)
         timesheet_logger.info("data sent to minute entry field")
         self.wait.until(
             EC.element_to_be_clickable(
                 (By.NAME, descript_entry))).send_keys(description)
         timesheet_logger.info("data sent to Description entry field")
         self.wait.until(EC.element_to_be_clickable(
             (By.XPATH, add_btn))).click()
         timesheet_logger.info("add button was visible and now clicked")
         # self.update_globals(hrs, mins)
     except:
         MyLibrary.save_screenshot_picture(driver, 'add_entry')
         raise
 def enter_password(self, password):
     try:
         field = self.wait.until(
             EC.element_to_be_clickable((By.NAME, password_field)))
         login_logger.info("Password field is located")
         field.send_keys(password)
         login_logger.info("Password is send as key to the password field")
         next_btn = self.wait.until(
             EC.element_to_be_clickable((By.ID, pass_nxt_btn))).click()
         login_logger.info("Next Button clicked after entring password")
         try:
             pass_field = self.wait.until(
                 EC.element_to_be_clickable((By.NAME, password_field)))
             login_logger.info("Trying to located password input field")
             return -1
         except:
             login_logger.info(
                 "Failed to Locate password field means Password was correct"
             )
             return 1
     except:
         MyLibrary.save_screenshot_picture(self.driver,
                                           'enter for password')
         raise