def login_with_account(self): """ facebook login with username and password """ self.get(self.url) try: # username email_element = WebDriverWait(self.driver, timeout=10).until( EC.presence_of_element_located((By.ID, "email"))) email_element.clear() email_element.send_keys(self.email) self.driver.implicitly_wait(1) # password password_element = WebDriverWait(self.driver, timeout=10).until( EC.presence_of_element_located((By.ID, "pass"))) password_element.clear() password_element.send_keys(self.password) self.driver.implicitly_wait(1) # click login_element = WebDriverWait(self.driver, timeout=10).until( EC.presence_of_element_located((By.ID, "loginbutton"))) login_element.click() except: pass
def order_item(self, response): self.logger.warning("Order Item " + response.meta['cbarre'] + " => Qte " + response.meta['qte']) response.meta['driver'] = self.driver time.sleep(0.5) #open_in_browser(response) try: url_detail = response.xpath( '//div[@class="listeProduit"]//div[@class="pdt-libelle"]/a/@href' ).extract() url_detail = u'https://grenoble.promocash.com' + url_detail[0] except: self.cbarre_notfound.append(response.meta['cbarre']) return None self.driver.get(url_detail) #f = codecs.open("out_" + response.meta['cbarre'] + ".html", 'w', "utf-8") #f.write(self.driver.page_source) #f.flush() #f.close() qte = WebDriverWait(self.driver, 10).until( EC.visibility_of_element_located((By.ID, 'PRO_QUANTITE'))) qte.clear() qte.send_keys(response.meta['qte']) order_btn = WebDriverWait(self.driver, 10).until( EC.visibility_of_element_located( (By.XPATH, '//input[@id="SUBM"]'))) order_btn.click() return None
def fill_login(driver, username, password): # Finding the auth boxes by CSS Selectors username_box = WebDriverWait(driver, 10).until( EC.element_to_be_clickable((By.CSS_SELECTOR, config.AUTH_USER_SEL))) password_box = WebDriverWait(driver, 10).until( EC.element_to_be_clickable((By.CSS_SELECTOR, config.AUTH_PASS_SEL))) # Typing in the auth values provided username_box.clear() password_box.clear() username_box.send_keys(username) password_box.send_keys(password) # Finding the login button by CSS Selector and clicking on it login_btn = WebDriverWait(driver, 10).until( EC.element_to_be_clickable((By.CSS_SELECTOR, config.SUBMIT_SELECTOR))) login_btn.click() # Finding the "not now" buttons by XPATH and clicking on them not_now_btn = WebDriverWait(driver, 10).until( EC.element_to_be_clickable((By.XPATH, config.NOT_NOW_XPATH))) not_now_btn.click() not_now_btn2 = WebDriverWait(driver, 10).until( EC.element_to_be_clickable((By.XPATH, config.NOT_NOW_XPATH))) not_now_btn2.click()
def watch_zip_code(zip_code): driver = webdriver.Chrome() driver.get("https://www.walgreens.com/findcare/vaccination/covid-19") btn = driver.find_element_by_css_selector('span.btn.btn__blue') action = webdriver.ActionChains(driver) action.move_to_element(btn) action.click() action.perform() element = WebDriverWait(driver, 10).until( expected_conditions.presence_of_element_located((By.ID, "inputLocation")) ) element.clear() element.send_keys(zip_code) button = driver.find_element_by_css_selector("button.btn") while True: button.click() alert_element = WebDriverWait(driver, 10).until( expected_conditions.presence_of_element_located((By.CSS_SELECTOR, "p.fs16")) ) if alert_element.text == "Appointments available!": print("APPOINTMENT FOUND! ZIP CODE: ", zip_code) return time.sleep(5)
def google_login(driver): driver.get("https://voice.google.com/u/0/messages") try: icon = driver.find_element_by_xpath("//a[@class='signUpLink']") except: return icon.click() form = driver.find_element_by_xpath("//input[@id='Email']") form.clear() form.send_keys("*****@*****.**") driver.find_element_by_xpath("//input[@id='next']").click() while True: try: form = WebDriverWait(driver, 10).until( EC.visibility_of_element_located((By.ID, "Passwd"))) form.clear() form.send_keys("conchobang2") driver.find_element_by_xpath("//input[@id='signIn']").click() time.sleep(0.1) # pickle.dump(driver.get_cookies(), open("cookies.pkl", "wb")) break except: print("Waiting....")
def buy(self, amount): """ Buying the stock of the opened dialog :param amount: Amount """ # Finding amount input elem = WebDriverWait(self.driver, self.timeout).until( expected_conditions.visibility_of_element_located(( By.XPATH, "//div[@class='visible-input']//input[contains(@id, 'uniqName')]" ))) elem.clear() # Entering keys slowly because Trading212 removes it if it's written too fast type_sleep(elem, str(amount), self.short_sleep) # Confirm Button if self.mode == Mode.Invest: # The invest doesn't let you click on the button too fast sleep(self.long_sleep) self.driver.find_elements_by_xpath( "//div[@class='custom-button review-order-button']")[0].click( ) WebDriverWait(self.driver, self.timeout).until( expected_conditions.element_to_be_clickable( (By.XPATH, "//div[@class='custom-button send-order-button']" ))).click() else: self.driver.find_elements_by_xpath( "//div[contains(@class,'confirm-button')]")[0].click()
def login(): USERNAME = "" #INSERIR USERNAME <----------------------------------------------------------------------------- PASSWORD = "" #INSERIR PASSWORD <----------------------------------------------------------------------------- sign_In_page = driver.find_element_by_xpath( "/html/body/div[1]/header/div/div[2]/div[2]/a[1]") sign_In_page.click() try: ##GET EVERY ELEMENT username_fill = WebDriverWait(driver, 10).until( EC.presence_of_element_located((By.ID, "login_field"))) password_fill = WebDriverWait(driver, 10).until( EC.presence_of_element_located((By.ID, "password"))) log_in_Button = driver.find_element_by_name("commit") username_fill.clear() password_fill.clear() username_fill.send_keys(USERNAME) password_fill.send_keys(PASSWORD) log_in_Button.click() except: print("Failed in LOGIN function!!!")
def test_contact_key_creator(self): self.logger.info('Starting test_contact_key_creator') #setup the doc on gdrive first file_name = 'ContactKeyTest1' ss_key = gdoc_util.upload_file_to_gdrive('contact_key_test1.tsv', file_name) driver = self.driver gdoc_util.login_gdrive(driver) driver.get('%s%s' % (self.base_url, '?ss=' + ss_key)) gc = gspread.login(settings.DEFAULT_GDRIVE_EMAIL, settings.DEFAULT_GDRIVE_PW) my_worksheet = gc.open_by_key(ss_key).sheet1 e2_val = my_worksheet.acell('E2') self.logger.info('e2_val: %s' % e2_val) #reset the cell my_worksheet.update_acell('E2', '') e2_val = my_worksheet.acell('E2') self.logger.info('e2_val reset to: %s' %e2_val) #now run the command #switch to input form frame driver.switch_to.frame(0) WebDriverWait(driver, 10).until( EC.presence_of_element_located((By.LINK_TEXT, "Hiplead")) ).click() id_worksheet_name_INPUT = WebDriverWait(driver, 10).until( EC.presence_of_element_located((By.ID, "id_worksheet_name")) ) id_worksheet_name_INPUT.clear() id_worksheet_name_INPUT.send_keys(file_name) Select(driver.find_element_by_id("id_scrapers")).select_by_value('contactKeyCreator') driver.find_element_by_id("id_email").send_keys(settings.DEFAULT_GDRIVE_EMAIL) driver.find_element_by_id("id_password").send_keys(settings.DEFAULT_GDRIVE_PW) #ok, now submit the form id_worksheet_name_INPUT.submit() #then wait for task to complete #this success alert only becomes visible when task is actually finished. success_div = driver.find_element_by_class_name('time_remaining') try: WebDriverWait(driver, 10).until( EC.visibility_of(success_div) ) except StaleElementReferenceException as e: #TODO The javascript DOM manipulation that results in StaleElementReferenceException needs to be resolved. success_div = driver.find_element_by_class_name('time_remaining') WebDriverWait(driver, 10).until( EC.visibility_of(success_div) ) #now validate cell value, since we know task has completed. e2_val = my_worksheet.acell('E2') self.logger.info('e2_val after test: %s' %e2_val) self.assertEquals('john_franklin_smith_somedomain.net', e2_val.value) self.logger.info( 'Finished test_contact_key_creator')
def login_with_account(self): """ facebook login with username and password :return: a status code —— True: Success, False: False Note: 如果facebook账号登录成功,则当前页面的url为:https://www.facebook.com 如果facebook账号登录失败,则当前页面的url为:https://www.facebook.com/login.php?login_attempt=1&lwv=100 """ self.driver.get(self.url) try: # username email_element = WebDriverWait(self.driver, timeout=5).until( EC.presence_of_element_located((By.ID, "email"))) email_element.clear() email_element.send_keys(self.user_name) time.sleep(1) # password password_element = WebDriverWait(self.driver, timeout=5).until( EC.presence_of_element_located((By.ID, "pass"))) password_element.clear() password_element.send_keys(self.password) time.sleep(1) # click login_element = WebDriverWait(self.driver, timeout=5).until( EC.presence_of_element_located((By.ID, "loginbutton"))) login_element.click() except: pass
def write_blog(self): # 写入文章标题 ele_title = WebDriverWait(self.driver, self.timeout).until( lambda x: x.find_element_by_xpath("//*[@placeholder='请输入文章标题']")) ele_title.clear() ele_title.send_keys(self.title) # 写入文章正文 ele_edit = WebDriverWait( self.driver, self.timeout).until(lambda x: x.find_element_by_xpath( "//textarea[@placeholder='开始编辑...']")) ele_edit.clear() ele_edit.click() # 由于某些编辑器对输入有自动格式化,可通过模拟复制粘贴的方式解决 # ele_edit.send_keys(self.content) pyperclip.copy(self.content) k = pykeyboard.PyKeyboard() ele_edit.send_keys(Keys.CONTROL, 'a') ele_edit.send_keys(Keys.RETURN) time.sleep(1) # ele_edit.send_keys(Keys.CONTROL, 'v') k.press_keys(['Command', 'v']) k.press_keys(['Return']) time.sleep(1) # 点击发布按钮 ele_publish = self.driver.find_element_by_class_name( "ant-pro-footer-toolbar").find_element_by_xpath( "//button[@class='ant-btn ant-btn-primary']") ele_publish.click()
def login_jira(driver): if debug: print("login ", datetime.datetime.now()) if not is_configured_properly: driver.quit() print("Please set your name and password before access jira. ~/.gitdull/jira_config.py") exit(-1) driver.get(URL) try: user_name = WebDriverWait(driver, 20).until( ec.presence_of_element_located((By.ID, "login-form-username")) ) user_name.clear() user_name.send_keys(NAME) finally: pass pass_word = driver.find_element_by_id('login-form-password') pass_word.clear() pass_word.send_keys(PWD) submit = driver.find_element_by_id('login') submit.click() if debug: print("login submit ", datetime.datetime.now()) try: WebDriverWait(driver, 20, 0.5).until(is_login_jira) if debug: print("Login succeed", datetime.datetime.now()) finally: pass
def _make_order(self, url): bot = SEURobotFromFile(self.login_data_path) last_sec = datetime.datetime.now().second browser = bot.open(url) # 打开预约界面等着 validateCode = WebDriverWait( browser, 10).until(lambda x: x.find_element_by_id('validateCode')) while datetime.datetime.now().minute >= 10: # 至少要到整点后才能开始 now_sec = datetime.datetime.now().second if now_sec != last_sec: last_sec = now_sec logging.info('现在是%s,还不能预约' % datetime.datetime.now()) continue logging.info('现在是%s,可以开始预约' % datetime.datetime.now()) self.lock.acquire() validateCode.clear() validateCode.click() validateCode.send_keys(self.getValidateCode(browser, url)) browser.execute_script("submit()") now = datetime.datetime.now() fname = now.strftime("%Y%m%d-%H.%M.%S.") + str( now.microsecond) #记下提交的时间 self.lock.release() time.sleep(1) browser.get_screenshot_as_file("screenshots/" + fname + '.png') browser.close()
def driver_init(): print('开始模拟首次登陆') global driver # 2.模拟登陆 options = ChromeOptions() # 2.1.添加代理(根据自己电脑的代理设置) options.add_argument('--proxy-server=socks5://localhost:1087') # 2.2.消除chrome跳窗 prefs = { 'profile.default_content_setting_values' : { 'notifications' : 2 } } options.add_experimental_option('prefs',prefs) # 2.3.启动chromedriver浏览器 driver = start_chrome("www.facebook.com", headless=False, options=options) # 2.4.登录facebook # username email_element = WebDriverWait(driver, timeout=10).until(EC.presence_of_element_located((By.ID, "email"))) email_element.clear() email_element.send_keys(YOUR_EMAIL) driver.implicitly_wait(1) # password password_element = WebDriverWait(driver, timeout=10).until(EC.presence_of_element_located((By.ID, "pass"))) password_element.clear() password_element.send_keys(YOUR_PASSWORD) driver.implicitly_wait(1) # click login_element = WebDriverWait(driver, timeout=10).until(EC.presence_of_element_located((By.ID, "loginbutton"))) login_element.click() time.sleep(1) print('完成首次登陆!')
def login(self, result_string=None): # 显式等待,等待登陆出现 user = WebDriverWait(self.browser, 10).until(EC.presence_of_element_located( (By.XPATH, '//*[@id="name"]') )) psw = WebDriverWait(self.browser, 10).until(EC.presence_of_element_located( (By.XPATH, '//*[@id="pwd"]') )) yzm = WebDriverWait(self.browser, 10).until(EC.presence_of_element_located( (By.XPATH, '//*[@id="exPwd"]') )) # 登陆信息 user.clear() psw.clear() # yzm.clear() user.send_keys('xxxxxxxx') psw.send_keys('xxxxxxxx') yzm.send_keys('{}'.format(result_string)) #登陆按钮 button = WebDriverWait(self.browser, 10).until(EC.presence_of_element_located( ( By.XPATH, '/html/body/table/tbody/tr/td/table/tbody/tr[4]/td/table/tbody/tr[3]/td[1]/img') )) button.click()
def write_blog(self): self.driver.close() window_handles = self.driver.window_handles self.driver.switch_to.window(window_handles[-1]) # 1. 输入文章标题 title = WebDriverWait(self.driver, self.timeout).until(lambda x : x.find_element_by_xpath("//input[@class='article-bar__title article-bar__title--input text-input']")) ActionChains(self.driver).click(title).perform() title.clear() title.send_keys(Keys.CONTROL, 'a') title.send_keys(Keys.DELETE) title.send_keys(self.title) # PS:下面这行代码很重要,卡了好久才解决┭┮﹏┭┮,不信可以试试注释掉这句 # 2.输入正文 通过键盘事件解决 editor = self.driver.find_element_by_xpath("//div[@class='cledit-section']") ActionChains(self.driver).click(editor).perform() pyperclip.copy(self.content) k = pykeyboard.PyKeyboard() time.sleep(1) k.press_keys(['Command', 'a']) k.press_keys(['Return']) time.sleep(0.5) k.press_keys(['Command', 'v']) k.press_keys(['Return']) time.sleep(2) # 3. 发布文章按钮 self.driver.find_element_by_xpath("//div[@class='article-bar__user-box flex flex--row']/button[@class='btn btn-publish']").click()
def login(): accept_cookies = WebDriverWait(driver, 10).until( EC.element_to_be_clickable( (By.XPATH, "//button[contains(text(), 'Aceptar todas')]"))).click() username = WebDriverWait(driver, 10).until( EC.element_to_be_clickable( (By.CSS_SELECTOR, "input[name= 'username']"))) password = WebDriverWait(driver, 10).until( EC.element_to_be_clickable( (By.CSS_SELECTOR, "input[name= 'password']"))) username.clear() password.clear() username.send_keys(USERNAME) password.send_keys(PASSWD) time.sleep(1) log_in = WebDriverWait(driver, 10).until( EC.element_to_be_clickable( (By.CSS_SELECTOR, "button[type='submit']"))).click() time.sleep(5) accept_cookies = WebDriverWait(driver, 10).until( EC.element_to_be_clickable( (By.XPATH, "//button[contains(text(), 'Ahora no')]"))).click() time.sleep(3) accept_cookies = WebDriverWait(driver, 10).until( EC.element_to_be_clickable( (By.XPATH, "//button[contains(text(), 'Ahora no')]"))).click()
def write(post, driver, timeout): write_link = 'https://www.jianshu.com/writer#/' driver.get(write_link) # 选择文集 __set_corpus(post, driver, timeout) time.sleep(3) # 新建文章 new_article = WebDriverWait(driver, timeout).until(lambda d: d.find_element_by_xpath('//*[@id="root"]/div/div[2]/div[1]/div/div/div/div[1]')) new_article.click() article = WebDriverWait(driver, timeout).until(lambda d: d.find_element_by_xpath('//*[@id="root"]/div/div[2]/div[1]/div/div/div/ul/li[1]')) article.click() time.sleep(3) # 添加标题 title = WebDriverWait(driver, timeout).until(lambda d: d.find_element_by_xpath('//*[@id="root"]/div/div[2]/div[2]/div/div/div/div/input')) pyperclip.copy(post.title) title.clear() title.send_keys(Keys.CONTROL, 'v') time.sleep(3) # 添加正文 content = WebDriverWait(driver, timeout).until(lambda d: d.find_element_by_id('arthur-editor')) pyperclip.copy(post.content) content.clear() content.send_keys(Keys.CONTROL, 'v') time.sleep(3) # 保存草稿 driver.find_element_by_class_name('fa-floppy-o').click()
def sendkeysElemByCSS_Presence(self, locator, key, timeout=2): """给存在dom里的元素组里的某个元素写入值CSS""" elem = WebDriverWait(self.driver, timeout).until( EC.presence_of_element_located((By.CSS_SELECTOR, locator))) self.driver.execute_script("arguments[0].scrollIntoView();", elem) elem.clear() elem.send_keys(key)
def __login(self, username_ig, password_ig): #Wait until the element be clickable => load it in the webpage username = WebDriverWait(self.__driver, 10).\ until(EC.element_to_be_clickable\ ((By.CSS_SELECTOR, "input[name='username']"))) password = WebDriverWait(self.__driver, 10).\ until(EC.element_to_be_clickable\ ((By.CSS_SELECTOR, "input[name='password']"))) #Cleaning the fields username.clear() username.send_keys(username_ig) password.clear() password.send_keys(password_ig) #Login login_button = WebDriverWait(self.__driver, 10)\ .until(EC.element_to_be_clickable\ ((By.CSS_SELECTOR, "button[type='submit']"))).click() #Skipping not now not_now = WebDriverWait(self.__driver, 10).\ until(EC.element_to_be_clickable\ ((By.XPATH, '//button[contains(text(), "Not Now")]'))).click() not_now2 = WebDriverWait(self.__driver, 10).\ until(EC.element_to_be_clickable\ ((By.XPATH, '//button[contains(text(), "Not Now")]'))).click()
def log_in(driver, username, password): username_element = driver.find_element_by_id('input_username') username_element.click() username_element.clear() username_element.send_keys(username) password_element = WebDriverWait(driver, 10).until( EC.element_to_be_clickable((By.ID, 'input_password'))) password_element.click() password_element.clear() password_element.send_keys(password) driver.find_element_by_xpath( "//div[@id='login_btn_signin']/button[1]").click() # Handle login errors including too many log-ins and wrong credentials time.sleep(5) if driver.find_element_by_id('error_display').is_displayed(): error_text = driver.find_element_by_id('error_display').text print(error_text) # If the error is "too many logins" error then close the application if "too many login failures" in error_text: sys.exit("Stopping application. Try again later") else: # While the login credentials are incorrect, keep asking the user for the correct credentials while driver.find_element_by_id('error_display').is_displayed(): print("Please give your Steam username and password again.\n") return False WebDriverWait(driver, 10).until( EC.element_to_be_clickable((By.ID, 'error_display'))) else: return True
class LoginScreen: def __init__(self, driver): #Constructor for Login Screen self.driver=driver self.username=WebDriverWait(self.driver.instance,20).until(expected_conditions.visibility_of_element_located((By.CSS_SELECTOR,"#username"))) self.password=WebDriverWait(self.driver.instance,20).until(expected_conditions.visibility_of_element_located((By.CSS_SELECTOR, "#password"))) #self.SignIn = self.driver.find_element_by_css_selector("button[ng-bind*='SIGN IN']") #self.Warning = self.driver.find_element_by_css_selector("span[class='warning']") def assign_values(self,user_name,pass_word): #Assign Values for Username and Password self.username.clear() self.password.clear() self.username.send_keys(user_name) self.password.send_keys(pass_word) def login(self): #Clicking the enter button to login self.SignIn = WebDriverWait(self.driver.instance, 20).until(expected_conditions.visibility_of_element_located((By.CSS_SELECTOR, "button[ng-bind*='SIGN IN']"))) self.SignIn.click() def warning_message(self): #Return warning text displayed on screen self.Warning = WebDriverWait(self.driver.instance, 20).until(expected_conditions.visibility_of_element_located((By.CSS_SELECTOR, "span[class='warning']"))) #self.Checkfield=WebDriverWaitself.driver.instance, 10).until(expected_conditions.visibility_of_element_located((By.CSS_SELECTOR, "span[class='f-size-1-rem']").__getattribute__())) return self.Warning.text
def test_login(self): driver = self.driver driver.get(self.base_url) support = WebDriverWait(driver, 10).until( EC.presence_of_element_located((By.LINK_TEXT, u"ПОДДЕРЖКА")) ) support.click() enter = WebDriverWait(driver, 10).until( EC.presence_of_element_located((By.LINK_TEXT, u"вход")) ) enter.click() email = WebDriverWait(driver, 10).until( EC.presence_of_element_located((By.ID, "user_email")) ) email.clear() email.send_keys("*****@*****.**") password = driver.find_element_by_id("user_password") password.clear() password.send_keys("rcthjy") login = driver.find_element_by_name("commit") login.click() self.assertEqual(u"Михаил", driver.find_element_by_id("top-right-name").text)
class BaseElement: def __init__(self, driver, by, locator, visible=True): self.driver = driver self.by = by self.source = (self.by, locator) self._web_element = None self.visible = visible if self.visible: self._initialize() def _initialize(self) -> object: self._web_element = WebDriverWait(self.driver, 10).until( EC.visibility_of_element_located(self.source)) return self._web_element def click(self) -> None: self._web_element = WebDriverWait(self.driver, 10).until( EC.element_to_be_clickable(self.source)) return self._web_element.click() @property def get_text(self) -> str: if not self.visible: self._initialize() return self._web_element.text def send_text(self, string) -> None: if not self.visible: self._initialize() self._web_element.clear() self._web_element.send_keys(string)
def send_value_to_text_box(self, element, text): try: test_element = WebDriverWait(self.driver, 10).until(EC.visibility_of(element)) test_element.clear() test_element.send_keys(text) except: raise Exception("Send value to text box didn't work")
def sendKeys_Xpath(self,element,data): try: myElem = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, element))) myElem.clear() myElem.send_keys(data) return True except TimeoutException: raise Exception('Given element is not displayed: '+element)
def send_text_to_element(self, text, locator, time_waiting_element=0): try: element = WebDriverWait(self.driver, time_waiting_element). \ until(EC.element_to_be_clickable(locator)) element.clear() element.send_keys(text) except TimeoutException: raise TimeoutException('Элемент не обнаружен!')
def enter_text_and_click_enter_and_wait_for_a_new_page( self, by_locators: tuple, text: str): old_page = self.driver.find_element_by_tag_name('html') element = WebDriverWait(self.driver, 100).until( EC.visibility_of_element_located(by_locators)) element.clear() element.send_keys(text + Keys.ENTER) WebDriverWait(self.driver, 100).until(staleness_of(old_page))
def clear_and_enter_value(self, by_locator, value, timeout=5): self.context.logger.info( f'Clear field and enter text "{value}" in Element located by {by_locator}' ) form_input = WebDriverWait(self.driver, timeout).until( expected_conditions.visibility_of_element_located(by_locator)) form_input.clear() form_input.send_keys(value)
def input_without_hide_keyboard(self, text): try: element = WebDriverWait(self.driver, 10).until( EC.element_to_be_clickable(locator=self.locator)) element.clear() element.set_value(text) except TimeoutException: print("ERROR: cannot click the element: ", sys.exc_info()[0]) return None
def search(self, key_word): search_input = WebDriverWait( self.driver, 10).until(lambda x: x.find_element_by_id("main-search-input")) search_input.click() search_input.clear() search_input.send_keys(key_word, Keys.ENTER) self.post_list_url = self.driver.current_url
def set_code(code): try: driver.switch_to_frame('main') except: pass ''' try: driver.find_element_by_link_text('QUOTES').click() except: pass ''' inbox = WebDriverWait(driver,10).until(lambda driver : driver.find_element_by_id('secCode')) inbox.clear() inbox.send_keys(code) driver.find_element_by_id('btnGoSI').click()
def Change_Amound_Component(self, amound): panel = self.Define_Panel_button() button = WebDriverWait(panel, 2).until( EC.element_to_be_clickable((By.XPATH, "./button[4]")) ) button.click() panel = self.Define_Panel_button() input = WebDriverWait(panel, 2).until( EC.presence_of_element_located((By.XPATH, "./input")) ) input.clear() input.send_keys(amound) panel = self.Define_Panel_after_change() button = WebDriverWait(panel, 3).until( EC.presence_of_element_located((By.XPATH, "./button[2]")) ) button.click()
def test_site(self): driver = self.driver driver.get(self.my_url) #Input account information signin_link = WebDriverWait(driver, 10).until( EC.presence_of_element_located((By.LINK_TEXT, "Sign In")) ) signin_link.click() #Email signin_email = WebDriverWait(driver, 10).until( EC.presence_of_element_located((By.ID, "signin-email")) ) signin_email.clear() signin_email.send_keys("*****@*****.**") #Password signin_password = driver.find_element_by_id("signin-password") signin_password.clear() signin_password.send_keys("******") driver.find_element_by_class_name("coursera-signin-button").click() #Check login user_name = WebDriverWait(driver, 10).until( EC.presence_of_element_located((By.CSS_SELECTOR, "span.coursera-header-account-name")) ) self.assertEqual(" Aleksey", user_name.text)
def set_campaign_name(self, name): element = WebDriverWait(self.driver, 30, 3).until( lambda el: el.find_element_by_css_selector(self.CAMPAIGN_NAME) ) element.clear() element.send_keys(name)
def set_banner_title(self, title): element = WebDriverWait(self.driver, 30, 3).until( lambda el: el.find_element_by_css_selector(self.BANNER_TITLE) ) element.clear() element.send_keys(title)
def set_banner_text(self, text): element = WebDriverWait(self.driver, 30, 3).until( lambda el: el.find_element_by_css_selector(self.BANNER_TEXT_AREA) ) element.clear() element.send_keys(text)
def set_campaign_name(self, name): edit_box = WebDriverWait(self.driver, WebDriverSettings.WEBDRIVER_TIMEOUT, WebDriverSettings.WEBDRIVER_POLL_FREQUENCY).until( lambda d: d.find_element_by_css_selector(self.CAMPAIGN_NAME) ) edit_box.clear() edit_box.send_keys(name)