Advertisement
Guest User

Untitled

a guest
Mar 7th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.72 KB | None | 0 0
  1. from selenium import webdriver
  2. from selenium.webdriver.common.by import By
  3. from selenium.webdriver.support.ui import Select
  4. from selenium.common.exceptions import NoSuchElementException
  5. from selenium.common.exceptions import TimeoutException
  6. import selenium.webdriver.support.ui as UI
  7. from selenium.webdriver.support import expected_conditions as EC
  8.  
  9. import time
  10.  
  11. "Use random var for the interval between clicks"
  12.  
  13. "Identify authorization credentials "
  14. baseurl = "myUrl"
  15. username = "myUser"
  16. password = "myPass
  17.  
  18. xpaths = {'usernameTxtBox': "//*[@id='Username']",
  19. 'passwordTxtBox': "//*[@id='Pass']",
  20. 'submitButton': "//*[@id='LogIn']",
  21. 'DashboardTableButton': "//*[@id='DashboardTable"
  22. }
  23. mydriver = webdriver.Chrome(
  24. executable_path='AppData\Local\Programs\Python\Python36-32\Scripts\chromedriver.exe')
  25. mydriver.get(baseurl)
  26. mydriver.maximize_window()
  27.  
  28. "Write Username"
  29. mydriver.find_element_by_xpath(xpaths['usernameTxtBox']).send_keys(username)
  30.  
  31. "Clear Password TextBox"
  32. mydriver.find_element_by_xpath(xpaths['passwordTxtBox']).clear()
  33.  
  34. "Write Password"
  35. mydriver.find_element_by_xpath(xpaths['passwordTxtBox']).send_keys(password)
  36.  
  37. "Click Login Button"
  38. mydriver.find_element_by_xpath(xpaths['submitButton']).click()
  39.  
  40. "Wait to click"
  41. mydriver.implicitly_wait(4)
  42.  
  43. "Click Button that leads to Dashboard"
  44. mydriver.find_element_by_xpath(xpaths['DashboardTableButton']).click()
  45.  
  46.  
  47.  
  48. "It is HERE where I am conceptually stuck"
  49.  
  50. mydriver.implicitly_wait(6)
  51.  
  52.  
  53. list_of_links = mydriver.find_elements_by_tag_name('h4') # Identify all the Links in the DashboardTable (there are 10 in each page)
  54.  
  55.  
  56.  
  57. for links in enumerate(list_of_links) :
  58. mydriver.implicitly_wait(4)
  59. for link in enumerate(links):
  60. link.click()
  61.  
  62. "Filter data"
  63. mydriver.find_element_by_xpath('//*[@id="status-wrapper"]/div/ul/li[3]/button').click()
  64. mydriver.find_element_by_xpath('//*[@id="header-bar-project-table"]/dt[1]/button').click()
  65. mydriver.find_element_by_xpath('//*[@id="filter-modal-content"]/li[1]/ul/li[2]/fieldset/h4/legend/button').click
  66. mydriver.find_element_by_xpath('//*[@id="search-facet-input-excludeActivities-true"]').click
  67. mydriver.find_element_by_xpath('//*[@id="search-facet-input-activityType-E"]').click
  68. mydriver.find_element_by_xpath('//*[@id="activityTimespan"]').click
  69. mydriver.find_element_by_xpath('//*[@id="activityTimespan"]/option[5]').click
  70. mydriver.find_element_by_xpath('//*[@id="dialog"]/div/div[2]/div/p/button[1]').click
  71.  
  72. "Save As"
  73. mydriver.find_element_by_xpath('//*[@id="all-checkbox"]').click
  74. mydriver.find_element_by_xpath('//*[@id="bulk-actions-bar"]/li[7]/button').click()
  75. mydriver.implicitly_wait(6)
  76.  
  77.  
  78.  
  79.  
  80. mydriver.quit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement