2

First time posting here, so I address a problem I cannot solve.Checked Stackoverflow and google. There's some answers for java which I couldn't decode. Therefore you might mention that this is a duplicate, but so far no one answered such a question.

Any ideas will be really appreciated.

from selenium import webdriver
from selenium.webdriver.firefox.firefox_profile import FirefoxProfile

from selenium.webdriver.firefox.firefox_binary import FirefoxBinary 
binary = FirefoxBinary(r'C:\Program Files (x86)\MozillaFirefox\firefox.exe')
profile = FirefoxProfile(r'C:\Users\User\Documents\dxcwavid.Zydrius5')
driver = webdriver.Firefox(firefox_profile = profile, firefox_binary = binary)
driver.get("http://google.com")

geckodriver: 0.23.0

python: 3.7.1

selenium: 3.141.0

Windows: 10 1511

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352

2 Answers2

1

Try with:

binary = FirefoxBinary("C:\Program Files (x86)\MozillaFirefox\firefox.exe")
profile = FirefoxProfile("C:\Users\User\Documents\dxcwavid.Zydrius5")
driver = webdriver.Firefox(firefox_profile=profile, firefox_binary=binary)
driver.get("http://google.com")
Infern0
  • 2,565
  • 1
  • 8
  • 21
  • SyntaxError '(Unicodeescape)' code can't decode bytes in position 2-3: Truncated \UXXXXXXXX escape – Zydrunas Agniauskas Dec 13 '18 at 11:13
  • try following this guide: https://stackoverflow.com/a/52935424/10413416 – Infern0 Dec 13 '18 at 11:16
  • That's why I put 'r' before string (r'C:\Program Files (x86)\MozillaFirefox\firefox.exe'). Besides the code runs perfectly this cannot be some syntax problem, instead I miss something or must be somewhere in Geckodrive... – Zydrunas Agniauskas Dec 13 '18 at 11:21
0

To load an existing Firefox Profile through Selenium and Python you can use the following solution:

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • @ZydrunasAgniauskas Of-coarse it works at my end flawless. Can you update the question with your latest code trials and error stacktrace for further analysis? – undetected Selenium Dec 13 '18 at 13:07
  • `from selenium import webdriver` `myprofile = webdriver.FirefoxProfile(r'C:\Users\User\Documents\Profile\dxcwavid.Zydrius5')` `driver = webdriver.Firefox(firefox_profile=myprofile, executable_path=r'C:\Users\User\Documents\Profile\geckodriver.exe')` `driver.get('https://www.google.co.in')` `print("Page Title is : %s" %driver.title)` Then I added to favorite, open again and nothing is marked as favorite. Cannot provide any errors as it doesn't produce any :) Also my firefox version 64.0 (32-bit) – Zydrunas Agniauskas Dec 13 '18 at 14:30
  • Here's geckodrive.log file https://drive.google.com/open?id=1GhB5niKfYpjGm-IvXs867IWvtw8M6dmt – Zydrunas Agniauskas Dec 13 '18 at 14:34
  • by which I understand that doesn't even bothering about my profile :) – Zydrunas Agniauskas Dec 13 '18 at 14:38
  • @ZydrunasAgniauskas Go through the link **Creating a new Firefox profile on Windows** within the second _Reference_ discussion within this answer. How did `dxcwavid.Zydrius5` land up in `C:\Users\User\Documents\Profile`? – undetected Selenium Dec 13 '18 at 14:43
  • I put everything in one place as well as geckodrive so the code would be easier to read, apologies to not inform you – Zydrunas Agniauskas Dec 13 '18 at 15:26
  • Also I did create the Profile as you in the link – Zydrunas Agniauskas Dec 13 '18 at 16:47