Advertisement
Guest User

Untitled

a guest
Aug 10th, 2017
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. profile = FirefoxProfile("/Users/username/Library/Application Support/Firefox/Profiles/jtokyple.selenium")
  2. self.driver = webdriver.Firefox(profile)
  3.  
  4. FF_PROFILE_PATH = os.path.join(os.environ['APPDATA'],
  5. 'Mozilla', 'Firefox', 'Profiles')
  6.  
  7. try:
  8. profiles = os.listdir(FF_PROFILE_PATH)
  9. except WindowsError:
  10. print "Could not find profiles directory."
  11. sys.exit(1)
  12. try:
  13. loc = (folder for folder in profiles
  14. if folder.endswith(profile)).next()
  15. except StopIteration:
  16. print "Firefox profile not found."
  17. sys.exit(1)
  18. return os.path.join(FF_PROFILE_PATH, loc)
  19.  
  20. # for fresh FF profile
  21. #profile = webdriver.FirefoxProfile()
  22. profile = webdriver.FirefoxProfile("./firefox_profiles/selenium")
  23. profile = webdriver.FirefoxProfile(profile_path)
  24. driver = webdriver.Firefox(firefox_profile=profile)
  25. driver.get("http://whatismyip.com")
  26.  
  27. import os
  28. import sys
  29. from selenium import webdriver
  30.  
  31.  
  32. def get_profile_path(profile):
  33. FF_PROFILE_PATH = os.path.join(os.environ['APPDATA'],'Mozilla', 'Firefox', 'Profiles')
  34.  
  35. try:
  36. profiles = os.listdir(FF_PROFILE_PATH)
  37. except WindowsError:
  38. print("Could not find profiles directory.")
  39. sys.exit(1)
  40. try:
  41. for folder in profiles:
  42. print(folder)
  43. if folder.endswith(profile):
  44. loc = folder
  45. except StopIteration:
  46. print("Firefox profile not found.")
  47. sys.exit(1)
  48. return os.path.join(FF_PROFILE_PATH, loc)
  49.  
  50. profile = get_profile_path("default")
  51. print(profile)
  52. driver = webdriver.Firefox(firefox_profile=profile)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement