Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from selenium import webdriver
- from selenium.webdriver.common.by import By
- from selenium.webdriver.support.ui import WebDriverWait
- from selenium.webdriver.support import expected_conditions as EC
- from selenium.common.exceptions import *
- import time
- class ReportingAutomation():
- def test_login(self):
- driver = webdriver.Safari()
- driver.maximize_window()
- driver.get("example_url")
- driver.implicitly_wait(3)
- username = "******"
- password = "*************"
- # Logging In
- username_field = driver.find_element(By.XPATH, ".//*[@id='ng-app']/div[1]/div/div/form/div[2]/div/div/input")
- username_field.send_keys(username)
- password_field = driver.find_element(By.XPATH, ".//*[@id='ng-app']/div[1]/div/div/form/div[3]/div/div/input")
- password_field.send_keys(password)
- login_link = driver.find_element(By.XPATH, ".//*[@id='ng-app']/div[1]/div/div/form/button")
- login_link.click()
- time.sleep(1)
- # Clicking Folder in Tableau
- 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']")
- set_click.click()
- time.sleep(1)
- # Clicks on the Specific Report to Open Dashboard
- 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")
- fuel_gauge_click.click()
- time.sleep(1)
- 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")
- # Finds and clicks the Filter Dash option
- filter_dash_click.click()
- # Targets and clicks the month parameters
- wait = WebDriverWait(driver, 10, poll_frequency=1,
- ignored_exceptions=[NoSuchElementException,
- ElementNotVisibleException,
- ElementNotSelectableException])
- element = wait.until(EC.element_to_be_clickable((By.XPATH,
- ".//*[@id='tableau_base_widget_CategoricalFilter_1']/div/div[3]/span/span")))
- element.click()
- # Beginning the for loop for each client
- # dropdown_list = driver.find_element()
- # for client in dropdown_list:
- ff = ReportingAutomation()
- ff.test_login()
Add Comment
Please, Sign In to add comment