def waitForVisibleElements(self, locator, wait=True, pH = {}, comp = '', locatorDimension = '', locatorText = '', parentDependency = 'True'): # self.driver = driver # if wait == True: if pH != {}: parentHandles = pH[0] eachComp = pH[1] tempChildHandles = [] if pH != {} and parentDependency == 'True': # for eachComp in parentHandles.keys(): if comp in self.configManager.componentChildRelations[eachComp]: if wait: print comp,locator try: CustomWebDriverWait(parentHandles[eachComp][len(parentHandles[eachComp])-1], Constants.WEBDRIVERTIMEOUT).until(EC.visibility_of_element_located(locator)) except Exception as e: logger.debug("Exception occured while getting the component with %s %s",locator,e) CustomWebDriverWait(self.driver, Constants.WEBDRIVERTIMEOUT).until(EC.visibility_of_element_located(locator)) # continue if locatorDimension != '': # tempChilds = [] for eachChild in parentHandles[eachComp][len(parentHandles[eachComp])-1].find_elements('xpath','.//*'): try: if locatorText in eachChild.get_attribute(locatorDimension): tempChildHandles.append(eachChild) except Exception as e: # logger.debug("SwitcherCard Selection : %s",screenInstance.switcher.getSelection(handles)) # logger.info("Called for DriverHelper.py :: LINE 69") # logger.debug("Exception Caught while getting handles for comp: %s , locatorDimension: %s , locatorText: %s , %s ", comp, locatorDimension, locatorText ) pass return tempChildHandles else: tempChildHandles = tempChildHandles + self.visibleCompsOnly(parentHandles[eachComp][len(parentHandles[eachComp])-1].find_elements(*locator)) return tempChildHandles else: if wait: try: CustomWebDriverWait(self.driver, Constants.WEBDRIVERTIMEOUT).until(EC.visibility_of_element_located(locator)) except Exception as e: logger.debug("Exception occured while getting the component with %s %s",locator,e) # continue else: pass # continue tempChildHandles = tempChildHandles + self.visibleCompsOnly(self.driver.find_elements(*locator)) return tempChildHandles else: if wait: try: CustomWebDriverWait(self.driver, Constants.WEBDRIVERTIMEOUT).until(EC.visibility_of_element_located(locator)) except Exception as e: logger.debug("Exception occured while getting the component with %s %s",locator,e) tempChildHandles = tempChildHandles + self.visibleCompsOnly(self.driver.find_elements(*locator)) return tempChildHandles
def waitForVisibleElementsAndChild(self, element_locator_pairs): # self.driver = driver dict_element_handlers = {} for element,locator in element_locator_pairs.iteritems(): CustomWebDriverWait(self.driver, Constants.WEBDRIVERTIMEOUT).until(EC.visibility_of_element_located(locator)) dict_element_handlers[element] = self.driver.find_element(*locator) return dict_element_handlers
def waitForVisibleElementsAndChilds(self, element_locator_pairs): # self.driver = driver dict_element_handlers = {} for element,locator in element_locator_pairs.iteritems(): print(element,locator) # parentHandles['btv'][0].find_elements('xpath','.//*')[2].get_attribute('class') try: CustomWebDriverWait(self.driver, Constants.WEBDRIVERTIMEOUT).until(EC.visibility_of_element_located(locator)) dict_element_handlers[element] = self.driver.find_elements(*locator) except: pass return dict_element_handlers
def waitForVisibleElement(self, locator, wait=True, isParent = False): # self.driver = driver if wait: CustomWebDriverWait(self.driver, Constants.WEBDRIVERTIMEOUT).until(EC.visibility_of_element_located(locator)) return self.driver.find_element(*locator)