Advertisement
Guest User

Untitled

a guest
Sep 7th, 2017
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.05 KB | None | 0 0
  1. from selenium import webdriver
  2. from selenium.webdriver.common.by import By
  3. from selenium.webdriver.support.ui import WebDriverWait
  4. from selenium.webdriver.support import expected_conditions as EC
  5. import uuid
  6.  
  7. # random_first_name = random_last_name = uuid.uuid4().hex
  8. random_first_name = 'auto_first_name_' + uuid.uuid4().hex
  9. random_last_name = 'auto_last_name_' + uuid.uuid4().hex
  10.  
  11. # arrange
  12. url = 'https://tst-04.test.intelliflo.com/nio/dashboard/userdashboard'
  13.  
  14. driver = webdriver.Chrome()
  15. driver.get(url)
  16.  
  17. login_button = driver.find_element(By.LINK_TEXT, 'Login')
  18. login_button.click()
  19.  
  20. username = driver.find_element(By.ID, 'username')
  21. password = driver.find_element(By.ID, 'password')
  22.  
  23. username.send_keys('vdamm04')
  24. password.send_keys('qWaszx12')
  25.  
  26. # act
  27. login_confirm = driver.find_element(By.CSS_SELECTOR, 'button.btn.btn-primary')
  28. login_confirm.click()
  29. add_client = driver.find_element_by_link_text('Add Client').click()
  30. add_client_iframe = driver.find_element(By.XPATH, '/html/body/div[11]/iframe')
  31. driver.switch_to.frame(add_client_iframe)
  32. first_name_control = driver.find_element_by_id('Life1FirstName')
  33. first_name_control.send_keys(random_first_name)
  34. last_name_control = driver.find_element_by_id('Life1LastName')
  35. last_name_control.send_keys(random_last_name)
  36. client_dob_control = driver.find_element_by_id('id_BasicDetailsStep_FirstLife_DateOfBirth')
  37. client_dob_control.send_keys('14/09/1984')
  38. finish_button = driver.find_element_by_css_selector('.complete.button.button-enabled')
  39. finish_button.click()
  40. driver.switch_to.default_content()
  41.  
  42.  
  43. # assert
  44. def assert_client_was_created():
  45.     text_to_look_for = random_first_name + ' ' + random_last_name
  46.     if text_to_look_for not in driver.page_source:
  47.         raise AssertionError("The client with the name {} was not created".format(text_to_look_for))
  48.     else:
  49.         print("The client was created - Test Passed")
  50.  
  51. wait = WebDriverWait(driver, 10)
  52. element = wait.until(EC.presence_of_element_located((By.XPATH, ".//*[@id='sidebar-container']/div/div")))
  53.  
  54. assert_client_was_created()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement