def Gotologinpage(self):
     try:
         element = self.driver.find_element_by_id(Locators.SignIn_Button_id)
         WebActions.click_on_element(self, element)
         Log.write_info_to_log_file(self, "Login successfully")
     except:
         print("")
Example #2
0
 def random_number_generator(self,start_number,end_number):        
     try:
         random_number = random.randint(start_number,end_number)
         Log.write_info_to_log_file(self,"random number return")
         return random_number          
     except ArithmeticError:
         Log.write_errors_to_log_file(self,"Random Number generation Failed")
 def hover_on_mouse_action(self,element):
     try:
         action = ActionChains(self.driver);
         action.move_to_element(element).perform();
         Log.write_info_to_log_file(self, "hover on mouse action performed successfully")
     except ElementNotInteractableException:
         Log.write_errors_to_log_file(self,"Element not found for hover action")
 def select_element_from_dropdown_by_value(self,element,value):
     try:
         s1 = Select(self.driver.find_element_by_id(element))
         s1.select_by_value(value)
         Log.write_info_to_log_file(self,"element is selected from dropdown")
     except ElementNotInteractableException:
         Log.write_errors_to_log_file(self,"Element not found")
Example #5
0
 def select_sofas_as_furniture_cateogry(self):
     try:
         element = self.driver.find_element_by_xpath(Locators.select_sofas_as_furniture_category_by_xpath)
         WebActions.click_on_element(self, element) 
         Log.write_info_to_log_file(self,"sofas as furniture category selected")
     except TimeoutException:
         Log.write_errors_to_log_file(self,"selection of furniture category failed")
Example #6
0
 def select_sofas_by_type(self):  
     try:
         sofas_type = self.driver.find_element_by_xpath(Locators.select_sofa_type_by_xpath)
         WebActions.click_on_element(self, sofas_type)
         Log.write_info_to_log_file(self,"sofa type selected successfully")
     except:
         Log.write_errors_to_log_file(self,"sofas type not selected")
 def check_element_enabled(self,element):
     try:
         element_status = element.is_enabled()
         Log.write_info_to_log_file(self,"Element is enabled")
         return element_status
     except ElementNotInteractableException:
         Log.write_errors_to_log_file(self,"Element not found")
 def add_cookies(self,cookie):
     #cookie is the variable which stored actual value like cookie:{'name':'foo','value':'bar'}
     try:
         self.driver.add_cookie(cookie)
         Log.write_info_to_log_file(self,"cookies added successfully")
     except:
         Log.write_errors_to_log_file(self,"cookies not added successfully")
 def enterusername(self, username):
     try:
         element = self.driver.find_element_by_id(
             Locators.Username_TextBox_id)
         WebActions.send_value_to_textbox(self, username, element)
         Log.write_info_to_log_file(self, "User name entered successfully")
     except:
         Log.write_errors_to_log_file(self, "Entering username failed")
Example #10
0
 def get_current_dir_path(self):
    
     try:
         dirpath = os.getcwd()
         Log.write_info_to_log_file(self,"Current Directory is:"+dirpath)
         return dirpath
     except:
         Log.write_errors_to_log_file(self,"Path not found")
Example #11
0
 def get_current_dir_folder_name(self):        
     try:
         dirpath = os.getcwd()
         foldername = os.path.basename(dirpath)
         Log.write_info_to_log_file(self, "Directory name is:"+foldername)
         return foldername
     except:
         Log.write_errors_to_log_file(self,"Path not found")
 def wait_for_element_clickablity(self, locator_method, locator):
     try:
         element = WebDriverWait(self.driver, 10).until(
             EC.element_to_be_clickable(locator_method, locator))
         Log.write_info_to_log_file(self, "Element is present")
         return element
     except NoSuchElementException:
         Log.write_errors_to_log_file(self, "Element not Found Exception")
Example #13
0
 def scroll_down_window(self):
     try:
         driver = self.driver
         Log.write_info_to_log_file(self,"Scroll to the bottom of the page")
         driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
     except TimeoutException:
         Log.write_errors_to_log_file(self,"window scrolling Failed")
         
 def wait_for_element_presence(self, locator_method, locator):
     try:
         element = WebDriverWait(self.driver, 10).until(
             EC.presence_of_element_located((locator_method, locator)))
         Log.write_info_to_log_file(self, "Element is present")
         return element
     except TimeoutException:
         Log.write_info_to_log_file(self, "Element is not present")
 def wait_for_element_visiblity(self, locator_method, locator):
     try:
         element = WebDriverWait(self.driver, 10).until(
             EC.visibility_of_element_located(locator_method, locator))
         Log.write_info_to_log_file(self, "Element is visible")
         return element
     except ElementNotVisibleException:
         Log.write_errors_to_log_file(self, "Element not visible")
Example #16
0
 def query_with_fetchone(self,query):
     try:
         cursor.execute(query)
         row = cursor.fetchone()
         Log.write_info_to_log_file(self, "Fetch next row from query result set or None in case there is no row left")
         return row
     except TimeoutException:
         Log.write_errors_to_log_file(self, "Error occurred while fetching records by using fetchone() method")
     mydb.close()
Example #17
0
 def read_certain_rows_from_csv_file(self, csv_file_path, number_of_rows):
     try:
         #number_of_rows value is 8 then it will return first 8 rows from cvs file
         data_frame = pandas.read_csv(csv_file_path, nrows=number_of_rows)
         Log.write_info_to_log_file(self,
                                    "specific rows read from csv file")
         return data_frame
     except FileNotFoundError:
         Log.write_errors_to_log_file(self, "File not Found")
Example #18
0
    def read_certain_columns_from_csv_file(self, csv_file_path, columns=[]):
        try:

            data_frame = pandas.read_csv(csv_file_path, usecols=columns)
            Log.write_info_to_log_file(self,
                                       "specific columns read from csv file")
            return data_frame.head()
        except FileNotFoundError:
            Log.write_errors_to_log_file(self, "File not found")
Example #19
0
 def execute_query_on_table(self,query,msg):
     try:
         cursor.execute(query)
         Log.write_info_to_log_file(self,msg)
     except TimeoutException:
         Log.write_errors_to_log_file(self, msg)
         
     #disconnect from server   
     mydb.close()   
 def enterpassword(self, password):
     try:
         element = self.driver.find_element_by_id(
             Locators.Password_TextBox_id)
         WebActions.send_value_to_textbox(self, password, element)
         Log.write_info_to_log_file(self,
                                    "Password value entered successfully")
     except:
         Log.write_errors_to_log_file(self, "Entering password failed")
 def clickonloginbutton(self):
     try:
         element = self.driver.find_element_by_id(Locators.Login_button_id)
         WebActions.click_on_element(self, element)
         Log.write_info_to_log_file(self,
                                    "clicked on login button successfully")
     except:
         Log.write_errors_to_log_file(self,
                                      "clicked on login button failed")
 def read_data_from_excel_file(self, excle_file_path, sheet_name):
     try:
         data_frame = pandas.read_excel(excle_file_path,
                                        sheet_name=sheet_name)
         return data_frame
         Log.write_info_to_log_file(
             self, "Data read successfully from excel file")
     except FileNotFoundError:
         Log.write_errors_to_log_file(self, "File Not Found")
Example #23
0
 def navigatebacktoHomepage(self):
     try:
         element = self.driver.find_element_by_class_name(
             Locators.Nav_home_page_class_name)
         WebActions.click_on_element(self, element)
         Log.write_info_to_log_file(self,
                                    "Navigate to Home Page successfully")
     except:
         Log.write_errors_to_log_file(
             self, "Navigation to Home Page is not successfully")
Example #24
0
 def checkOrders(self):
     try:
         element = self.driver.find_element_by_id(
             Locators.Nav_order_page_class_name)
         WebActions.click_on_element(self, element)
         Log.write_info_to_log_file(self,
                                    "Element is clicked on successfully")
     except:
         Log.write_errors_to_log_file(
             self, "Element is not clicked successfully")
    def wait_for_element_invisiblity(self, locator_method, locator):
        try:
            element = WebDriverWait(self.driver, 10).until(
                EC.invisibility_of_element_located(locator_method, locator))
            Log.write_info_to_log_file(self, "Element Found")
            return element

        except TimeoutError:
            Log.write_errors_to_log_file(
                self, "Element not found Timeout error occured")
 def wait_for_element_to_find_by_text(self, locator_method, locator,
                                      inner_text):
     try:
         element = WebDriverWait(self.driver, 10).unit(
             EC.text_to_be_present_in_element(locator_method, locator,
                                              inner_text))
         Log.write_info_to_log_file(self, "Element is present")
         return element
     except:
         Log.write_errors_to_log_file(self, "Element Text Not Found")
 def clickfornextloginpage(self):
     try:
         element = self.driver.find_element_by_id(
             Locators.Continue_Button_id)
         WebActions.click_on_element(self, element)
         Log.write_info_to_log_file(
             self, "Navigate to next Login page successfully")
     except:
         Log.write_errors_to_log_file(self,
                                      "Click on next login button Failed")
Example #28
0
    def read_data_from_csv_file(self, csv_file_path):
        try:

            data = pandas.read_csv(csv_file_path, index_col=0)
            Log.write_info_to_log_file(self,
                                       "Data read successfully from file")
            return data
        except FileNotFoundError:
            Log.write_errors_to_log_file(self,
                                         "Data reading from csv file failed")
Example #29
0
 def fetch_all_rows(self,query):
     try:
         cursor.execute(query) 
         rows = cursor.fetchall()
         total_row_count = cursor.rowcount
         Log.write_info_to_log_file(self, "Fetch all rows from tabel and rows count will be :"+total_row_count)
         return rows 
     except TimeoutException:
         Log.write_errors_to_log_file(self, "Error occurred while fetching records from table")
         
     mydb.close()
Example #30
0
 def execute_query_on_records_from_DB(self,query,msg):
     try:
         #Execute the SQL command
         cursor.execute(query)
         Log.write_info_to_log_file(self,msg)
         mydb.commit()
     except TimeoutException:
         #rollback in case there is any error
         mydb.rollback()
         Log.write_errors_to_log_file(self, msg)  
         
     mydb.close()