Best Python code snippet using robotframework-ioslibrary_python
tinder_bot.py
Source:tinder_bot.py
...130 except IndexError:131 print("Trying to switch windows one more time...")132 sleep(self.config.short_wait)133 continue134 def _element_exists(self, xpath):135 """136 Used mainly to check for Tinder antibot procedures.137 """138 try:139 self.driver.find_element_by_xpath(xpath)140 return True141 except NoSuchElementException as e:142 print("Tinder is trying to prevent us, that won't help it a lot though...")143 return False144 def _attempt_login(self):145 if self._element_exists(self.config.fb_btn_xpath):146 self._persist_pressing_a_button(self.config.fb_btn_xpath)147 elif self._element_exists(self.config.login_btn_xpath):148 self._persist_pressing_a_button(self.config.login_btn_xpath)149 sleep(self.config.swipe_wait)150 self._persist_pressing_a_button(self.config.fb_btn_xpath)151 self._persist_pressing_a_button(self.config.more_options_btn_xpath)152 elif self._element_exists(self.config.more_options_btn_path):153 self._persist_pressing_a_button(self.config.more_options_btn_xpath)154 self._persist_pressing_a_button(self.config.fb_btn_xpath)155 def login(self):156 self.driver.get(self.config.tinder_url)157 print("TinderBot is starting, please wait...")158 sleep(self.config.long_wait)159 self._accept_cookies()160 self._attempt_login()161 self._switch_to_login()162 self._persist_pressing_a_button(self.config.popup1_btn_xpath)163 self._persist_pressing_a_button(self.config.popup2_btn_xpath)164 return self165 166 def auto_swipe(self):...
base.py
Source:base.py
...64 def _wait_url_to_match(self, pattern):65 return self._wait.until(ec.url_matches(pattern))66 def _query_selector(self, selector):67 try:68 if self._element_exists(selector):69 return self.driver.find_element(By.CSS_SELECTOR, selector)70 except NoSuchElementException:71 return f'{selector} elemento não encontrado, verifique'72 def _query_selector_all(self, selector):73 try:74 if self._element_exists(selector):75 self.driver.find_elements(By.CSS_SELECTOR, selector)76 except NoSuchElementException:77 return f'{selector} elementos não encontrados, verifique'78 def validate_exists(self, locator, selector):79 try:80 locator(By.CSS_SELECTOR, selector)81 except NoSuchElementException:82 return False83 return True84 def _elements_exists(self, selector):85 return self.validate_exists(self.driver.find_elements, selector)86 def _element_exists(self, selector):87 return self.validate_exists(self.driver.find_element, selector)88 def select_fields_text(self, element, text):89 select = Select(element)90 select.select_by_visible_text(text)91 def select_fields_value(self, element, value):92 sleep(1)93 select = Select(element)94 select.select_by_value(value)95 def click_button(self, button):96 try:97 self._wait_to_be_clickable(By.CSS_SELECTOR, self._buttons[button])98 self._query_selector(self._buttons[button]).click()99 except InvalidSelectorException:100 self._wait_to_be_clickable(By.XPATH, self._buttons[button])...
sberbank.py
Source:sberbank.py
...19 self.__driver = webdriver.Firefox()20 self.__driver.get("http://www.sberbank.ru/ru/person")21 WebDriverWait(self.__driver, 10).until(EC.presence_of_element_located(L.WIDGET_PARENT))22 WebDriverWait(self.__driver, 10).until(ajax_complete, "Timeout waiting for page to load")23 def _element_exists(self, selector, value):24 try:25 self.__driver.find_element(by=selector, value=value)26 except NoSuchElementException:27 return False28 else:29 return True30 def click_metals(self):31 WebDriverWait(self.__driver, 10).until(EC.presence_of_element_located(L.METALS_BUTTON))32 self.__driver.find_element(*L.METALS_BUTTON).click()33 WebDriverWait(self.__driver, 10).until(EC.presence_of_element_located(L.METALS_BUTTON))34 def metals_active(self):35 WebDriverWait(self.__driver, 10).until(ajax_complete, "Timeout waiting for page to load")36 return self._element_exists(*L.PALLADIUM)37 def click_info(self):38 info = L.DOLLAR_INFO if not self.metals_active() else L.METAL_INFO39 logo = L.NEW_LOGO if not self.metals_active() else L.METAL_LOGO40 WebDriverWait(self.__driver, 10).until(EC.presence_of_element_located(info))41 self.__driver.find_element(*info).click()42 WebDriverWait(self.__driver, 10).until(EC.presence_of_element_located(logo))43 WebDriverWait(self.__driver, 10).until(ajax_complete, "Timeout waiting for page to load")44 def close(self):45 self.__driver.quit()46 @property47 def url(self):...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!