Advertisement
Guest User

selenium in functions

a guest
Jan 24th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.48 KB | None | 0 0
  1. import selenium, sys
  2. from selenium import webdriver
  3.  
  4. def Firefox_get():
  5.     global driver
  6.     driver = webdriver.Firefox()#calls gecko driver
  7.     driver.maximize_window()
  8.  
  9. def Chrome_get():
  10.     global driver
  11.     driver = webdriver.Chrome()
  12.     driver.maximize_window()
  13.  
  14. def Quitting():
  15.     driver.quit()
  16.     sys.exit()
  17.  
  18. def URL_Entry():
  19.     global where
  20.     where = input("Please type in the url for the website you wish to visit. ")
  21.     driver.get('%s') % (where)#tells driver what URL to open
  22.  
  23. def HTML_ID():
  24.     global html_id, message
  25.     html_id = input("Please enter the html ID of the form field you wish to type into. ")
  26.     message = input ("Please enter the information you with to type into the selcted field ")
  27.     driver.find_element_by_id("%s").send_keys("%s") %(html_id, message)
  28.  
  29. def By_Name_Button():
  30.     global name
  31.     name = input("Please enter the name identifier for the button you wish to press. ")
  32.     driver.find_element_by_name("%s").click()%(name)#finds the search button and emulates a left mouse click
  33.  
  34. def By_Partial_Text():
  35.     global partial_text
  36.     partial_text = input("Please type in the information you wish to seek then select. ")
  37.     driver.find_element_by_partial_link_text("%s").click()%(partial_text)
  38.  
  39. def Screen_Shots():
  40.     global path_name
  41.     path_name = input ("Please enter the file path and name of the screen shot's save location. ")
  42.     driver.get_screenshot_as_file("%s")%(path_name)#saves a screen shot to the project folder
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement