def step_impl(context): driver: WebDriver = context.driver WebDriverWait(driver, 10).until( ec.presence_of_element_located((By.ID, 'username'))) driver.find_element_by_id('username').send_keys("desty123") sleep(5)
def step_impl(context): driver: WebDriver = context.driver WebDriverWait(driver, 10).until( ec.presence_of_element_located((By.ID, 'password'))) driver.find_element_by_id('password').send_keys("sup") print("Login as Supervisor") sleep(5)
def test_ayush(self): driver = self.driver driver.get("https://twitter.com/home") username = driver.find_element_by_xpath( "/html/body/div/div/div/div[2]/main/div/div/div[2]/form/div/div[1]/label/div/div[2]/div/input" ) driver.implicitly_wait(10) password = driver.find_element_by_xpath( "/html/body/div/div/div/div[2]/main/div/div/div[2]/form/div/div[2]/label/div/div[2]/div/input" ) driver.implicitly_wait(10) username.send_keys("ayush_tamra") password.send_keys("") driver.implicitly_wait(10) login_button = driver.find_element_by_xpath( "/html/body/div/div/div/div[2]/main/div/div/div[2]/form/div/div[3]/div/div/span/span" ) login_button.click() driver.implicitly_wait(10) search = driver.find_element_by_xpath( "/html/body/div[2]/div/div/div[2]/main/div/div/div/div[2]/div/div[2]/div/div/div/div[1]/div/div/div/form/div[1]/div/div/div[2]/input" ) search.click() # driver.find_element_by_xpath("//input[@value='']").clear() driver.find_element_by_xpath( "/html/body/div[2]/div/div/div[2]/main/div/div/div/div[2]/div/div[2]/div/div/div/div[1]/div/div/div/form/div[1]/div/div/div[2]/input" ).send_keys("#URGENT") driver.find_element_by_xpath( "/html/body/div[2]/div/div/div[2]/main/div/div/div/div[2]/div/div[2]/div/div/div/div[1]/div/div/div/form/div[1]/div/div/div[2]/input" ).send_keys(Keys.ENTER) driver.find_element_by_link_text("Latest").click() driver.find_element_by_id("tweet-text").click() driver.find_element_by_id("tweet-text").click() UserText = driver.find_element_by_xpath( "//div[@id='tweet-text']/span[4]").text
def login(): # 네이버 로그인 열기 driver = webdriver.Chrome() driver.get('https://nid.naver.com/nidlogin.login') # id, pw 입력할 곳을 찾습니다. tag_id = driver.find_element_by_name('id') tag_pw = driver.find_element_by_name('pw') tag_id.clear() time.sleep(1) # id 입력 tag_id.click() # pyperclip.copy(idEntry.get()) pyperclip.copy("tkddnr701") tag_id.send_keys(Keys.CONTROL, 'v') time.sleep(1) # pw 입력 tag_pw.click() # pyperclip.copy(pwEntry.get()) pyperclip.copy("1q2w3e4r") tag_pw.send_keys(Keys.CONTROL, 'v') time.sleep(1) # 로그인 버튼을 클릭합니다 login_btn = driver.find_element_by_id('log.login') login_btn.click()
def test_blog(self): user = "******" pwd = "instructor1a" driver = self.driver driver.maximize_window() driver.get("https://byzantium-travel.herokuapp.com/home/") time.sleep(1) elem = driver.find_element_by_xpath( "/html/body/nav/nav[2]/div/div/ul[1]/li[2]/a").click() time.sleep(5) # Login Test scripts go elem = driver.find_element_by_id("id_username") elem.send_keys(user) elem = driver.find_element_by_id("id_password") elem.send_keys(pwd) elem.send_keys(Keys.RETURN) time.sleep(5) driver.get("https://byzantium-travel.herokuapp.com/planner/#category") time.sleep(5)
def test_blog(self): driver = self.driver driver.maximize_window() driver.get("https://byzantium-travel.herokuapp.com/home/") time.sleep(1) elem = driver.find_element_by_xpath("/html/body/nav/nav[2]/div/div/ul[1]/li[3]/a").click() time.sleep(2) #elem = driver.find_element_by_id("chat-input") #elem.send_keys("This is a test post of text") inputElement = driver.find_element_by_id("chat-input") inputElement.send_keys('This is a test post of text') time.sleep(2) inputElement.send_keys(Keys.ENTER) time.sleep(5)
def select_element_by_type(select_by, selector): driver = Driver().get_driver() selected_element = None try: if select_by is SelectBy.ID: selected_element = driver.find_element_by_id(selector) elif select_by is SelectBy.XPATH: selected_element = driver.find_element_by_xpath(selector) elif select_by is SelectBy.CSS_SELECTOR: selected_element = driver.find_element_by_css_selector( selector) elif select_by is SelectBy.CLASS_NAME: selected_element = driver.find_element_by_class_name(selector) elif select_by is SelectBy.TAG_NAME: selected_element = driver.find_element_by_tag_name(selector) except: return None else: return selected_element
def test_02_add_user(self): driver = self.driver # # driver.get("https://online.actitime.com/ssarangmath/login.do") # # lgn = LoginPage(driver) # lgn.enter_username("*****@*****.**") # lgn.enter_pwd("Shar@8971") # lgn.click_login() # driver.implicitly_wait(10) # time.sleep(3) # # # Verify successful login # pageTitle = self.driver.title # self.assertEqual("actiTIME - Enter Time-Track", pageTitle, "Login not success") driver.find_element_by_xpath( "//*[@id='topnav']/tbody/tr/td[5]/a").click() driver.implicitly_wait(20) driver.find_element_by_xpath( "//*[@id='pageBody']/tbody/tr[1]/td[3]/div/div[3]").click() driver.find_element_by_id("createUserPanel_firstNameField").clear() driver.find_element_by_id("createUserPanel_firstNameField").send_keys( "Sharath") driver.find_element_by_id("createUserPanel_lastNameField").clear() driver.find_element_by_id("createUserPanel_lastNameField").send_keys( "Sarangmath") driver.find_element_by_id("createUserPanel_emailField").clear() driver.find_element_by_id("createUserPanel_emailField").send_keys( "createUserPanel_emailField")