Advertisement
Guest User

Untitled

a guest
Nov 26th, 2017
530
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.61 KB | None | 0 0
  1.  
  2. from selenium import webdriver
  3. from selenium.webdriver.common.by import By
  4. from selenium.webdriver.support.ui import WebDriverWait
  5. from selenium.webdriver.support import expected_conditions as EC
  6. import unittest
  7.  
  8. class TestWork(unittest.TestCase):
  9.     @classmethod
  10.     def setUpClass(cls):
  11.         cls.url = "https://www.youtube.com/"
  12.         cls.driver = webdriver.Chrome()
  13.         cls.driver.implicitly_wait(10)
  14.         cls.username = "testirovsiktest@gmail.com"
  15.         cls.login_button_xpath = "//*[@id='button']/*[text()='Войти']"
  16.         cls.password = "testirovsiktest1234567890"
  17.  
  18.     @classmethod
  19.     def tearDownClass(cls):
  20.         cls.driver.quit()
  21.  
  22.     def login(self, username, password):
  23.         sign_button = WebDriverWait(self.driver, 20).until(
  24.             EC.element_to_be_clickable((By.XPATH, self.login_button_xpath))
  25.         )
  26.         sign_button.click()
  27.         self.driver.find_element_by_xpath("//input[@type='email']").send_keys(username)
  28.         self.driver.find_element_by_id("identifierNext").click()
  29.         self.driver.find_element_by_xpath("//input[@name='password']").send_keys(password)
  30.         self.driver.find_element_by_id("passwordNext").click()
  31.  
  32.     def upload_video(self, title, description, path_to_file):
  33.         pass
  34.  
  35.     def test_work_youtube(self):
  36.         self.driver.get(self.url)
  37.         self.login(self.username, self.password)
  38.         self.driver.implicitly_wait(10)
  39.         self.driver.find_element_by_xpath("//*[@id='buttons']//*[@id='button']").click()
  40.         self.driver.find_element_by_xpath("//input[@type='file']").send_keys("F:\\hey\\mouse.3gp")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement