Guest User

Untitled

a guest
Jan 18th, 2018
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.49 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. from selenium.common.exceptions import *
  6. import time
  7.  
  8.  
  9. class ReportingAutomation():
  10.  
  11. def test_login(self):
  12. driver = webdriver.Safari()
  13. driver.maximize_window()
  14. driver.get("example_url")
  15. driver.implicitly_wait(3)
  16.  
  17. username = "******"
  18. password = "*************"
  19.  
  20. # Logging In
  21. username_field = driver.find_element(By.XPATH, ".//*[@id='ng-app']/div[1]/div/div/form/div[2]/div/div/input")
  22. username_field.send_keys(username)
  23.  
  24. password_field = driver.find_element(By.XPATH, ".//*[@id='ng-app']/div[1]/div/div/form/div[3]/div/div/input")
  25. password_field.send_keys(password)
  26.  
  27. login_link = driver.find_element(By.XPATH, ".//*[@id='ng-app']/div[1]/div/div/form/button")
  28. login_link.click()
  29.  
  30. time.sleep(1)
  31.  
  32. # Clicking Folder in Tableau
  33. set_click = driver.find_element(By.XPATH, ".//a[@href='#/site/DSplus/projects/50/workbooks']//div[@class='tb-card-view-footer-cell-contents']//span[text()='Workbooks']")
  34. set_click.click()
  35.  
  36. time.sleep(1)
  37.  
  38. # Clicks on the Specific Report to Open Dashboard
  39. fuel_gauge_click = driver.find_element(By.XPATH, ".//*[@id='ng-app']/div[1]/div/div[1]/div/div/div[2]/div/div[3]/div/div/div/div/div/div/span[3]/a[1]/span")
  40. fuel_gauge_click.click()
  41.  
  42. time.sleep(1)
  43.  
  44. filter_dash_click = driver.find_element(By.XPATH, ".//*[@id='ng-app']/div[1]/div/div[1]/div/div/div[2]/div/div[3]/div/div/div/div/div/div/span[1]/a[1]/span")
  45. # Finds and clicks the Filter Dash option
  46. filter_dash_click.click()
  47.  
  48. # Targets and clicks the month parameters
  49. wait = WebDriverWait(driver, 10, poll_frequency=1,
  50. ignored_exceptions=[NoSuchElementException,
  51. ElementNotVisibleException,
  52. ElementNotSelectableException])
  53.  
  54. element = wait.until(EC.element_to_be_clickable((By.XPATH,
  55. ".//*[@id='tableau_base_widget_CategoricalFilter_1']/div/div[3]/span/span")))
  56. element.click()
  57.  
  58. # Beginning the for loop for each client
  59. # dropdown_list = driver.find_element()
  60. # for client in dropdown_list:
  61.  
  62.  
  63. ff = ReportingAutomation()
  64. ff.test_login()
Add Comment
Please, Sign In to add comment