def __call__(self, ignored): if self.elements != None: if type(self.elements) == list: self.elems = [ element for element in self.elements if EC._element_if_visible(element) ] if len(self.elems) > 0: self.elem = self.elems[0] return self.elem else: self.elem = EC._element_if_visible(self.elements) return self.elem elif self.locators_list != None and self.element_name != None: for key, val in self.locators_list.items(): if key == self.element_name: if val[0] == 'Finds': self.elems = [ element for element in Driver.get().find_elements( val[1], val[2]) if EC._element_if_visible(element) ] if len(self.elems) > 0: self.elem = self.elems[0] return self.elem elif val[0] == 'Find': self.elem = EC._element_if_visible( Driver.get().find_element(val[1], val[2])) return self.elem else: pass
def waiting_for_element_is_visible(elements=None, locators_list=None, element_name=None, time_out=BaseTest.timeout): try: if elements != None: return WebDriverWait(Driver.get(), time_out).until(lambda x: element_is_visible( elements=elements).__call__(ignored=None)) elif locators_list != None and element_name != None: return WebDriverWait( Driver.get(), time_out).until(lambda x: element_is_visible( locators_list=locators_list, element_name=element_name). __call__(ignored=None)) except: raise NoSuchElementException('AIST-element is not visible')
def test_ndp_checking_donor_by_fic_fullname_b(self): main_page = DonorsModuleRegistryPage() main_page.clear_localstorage() change_donor_settings(UseFicDonorSearch='true') main_page.open() query = sql_query( '''select top (1) PerC.IdentityDocSerie, PerC.IdentityDocNumber, PerC.LastName + ' ' + PerC.FirstName + ' ' + PerC.MiddleName OR1 from aistdb_fic.dbo.PersonCards PerC where len(PerC.LastName) > 0 and len(PerC.FirstName) > 0 and len(PerC.MiddleName) > 0 and len(PerC.IdentityDocSerie) > 0 and len(PerC.IdentityDocNumber) > 0''', stand= "DRIVER={SQL Server};SERVER=10.36.200.79;DATABASE=aistdb_fic;UID=sa;PWD=Mos111222" ) document_serie = query[0][0] document_number = query[0][1] expected = query[0][2] main_page.newdonor_click() main_page.ndp_filling_first_page("Сидоров", "Кирилл", '', "01.06.1980", document_serie, document_number) main_page.select_gender('male') aistium.click_on(elements=main_page.next_step_ndp) main_page.loading_is_completed() main_page.if_donor_is_in_local_cabinet() main_page.ndp_results_by_fic_is_on_the_page() main_page.ndp_results_by_fic_get_grid_values('ФИО', 0, mode='click') Driver.get().switch_to.window(Driver.get().window_handles[1]) assert main_page.query_to_fic_get_fullname() == expected
def loading_is_completed(cls): time.sleep(2) while 1: try: WebDriverWait(Driver.get(), 2).until( EC.visibility_of_any_elements_located( (By.CLASS_NAME, 'k-loading-image'))) continue except: time.sleep(1) break
def create_driver(request, language): platform = request.config.option.platform assert platform in POSSIBLE_PLATFORM cap = open(f'configuration_data/{platform}_config.json').read() capabilities = json.loads(cap) if platform == ANDROID_TYPE and language: change_language_android(language) elif platform == IOS_TYPE: capabilities["language"] = language driver = WebDriver("http://0.0.0.0:4723/wd/hub", desired_capabilities=capabilities) driver._platform = platform driver.implicitly_wait(5) request.addfinalizer(driver.quit) return Driver(driver)
def issued_by(cls): return Driver.get().find_element_by_css_selector('span.bold').text
def social_status(cls): return Driver.get().find_elements( by=L['personal_content_back_address_and_jobs'][1], value=L['personal_content_back_address_and_jobs'][2])[3].text
def job_place(cls): return Driver.get().find_elements( by=L['personal_content_back_address_and_jobs'][1], value=L['personal_content_back_address_and_jobs'][2])[1].text
def get_url(self): return Driver.get().current_url
def get_title(self): return Driver.get().title
def __init__(self, url): BasePage.__init__(self, Driver.get(), url)
def get_directed_date_value(cls): return Driver.get().find_element_by_id('directedDate').text
def switch_to_target_tab(ind): Driver.get().switch_to.window(Driver.get().window_handles[ind])