Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- profile = FirefoxProfile("/Users/username/Library/Application Support/Firefox/Profiles/jtokyple.selenium")
- self.driver = webdriver.Firefox(profile)
- FF_PROFILE_PATH = os.path.join(os.environ['APPDATA'],
- 'Mozilla', 'Firefox', 'Profiles')
- try:
- profiles = os.listdir(FF_PROFILE_PATH)
- except WindowsError:
- print "Could not find profiles directory."
- sys.exit(1)
- try:
- loc = (folder for folder in profiles
- if folder.endswith(profile)).next()
- except StopIteration:
- print "Firefox profile not found."
- sys.exit(1)
- return os.path.join(FF_PROFILE_PATH, loc)
- # for fresh FF profile
- #profile = webdriver.FirefoxProfile()
- profile = webdriver.FirefoxProfile("./firefox_profiles/selenium")
- profile = webdriver.FirefoxProfile(profile_path)
- driver = webdriver.Firefox(firefox_profile=profile)
- driver.get("http://whatismyip.com")
- import os
- import sys
- from selenium import webdriver
- def get_profile_path(profile):
- FF_PROFILE_PATH = os.path.join(os.environ['APPDATA'],'Mozilla', 'Firefox', 'Profiles')
- try:
- profiles = os.listdir(FF_PROFILE_PATH)
- except WindowsError:
- print("Could not find profiles directory.")
- sys.exit(1)
- try:
- for folder in profiles:
- print(folder)
- if folder.endswith(profile):
- loc = folder
- except StopIteration:
- print("Firefox profile not found.")
- sys.exit(1)
- return os.path.join(FF_PROFILE_PATH, loc)
- profile = get_profile_path("default")
- print(profile)
- driver = webdriver.Firefox(firefox_profile=profile)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement