Python Selenium Custom FireFox Profile Not Saving Data [duplicate] - python

This question already has answers here:
Python / Selenium / Firefox: Can't start firefox with specified profile path
(2 answers)
Closed 7 years ago.
So I've been experimenting with a custom firefox profile in my selenium project so that websites don't think I'm a new user every time. This is the code I'm using:
profile FirefoxProfile('C:\\Users\\Scott\\AppData\\Local\\Mozilla\\Firefox\\Profiles\\t3bxt79j.bot_profile')
binary = FirefoxBinary('C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe')
browser = webdriver.Firefox(firefox_profile=profile, firefox_binary=binary)
This code should link up to my profile that I created and the binary (which is already tested and working). However, every time I go to the website it acts like I'm a new user. None of my bookmarks on this profile are saving either and I'm making sure that I load firefox with the new profile.

It does save, but does not get back to you.
I've answered that just now here: https://stackoverflow.com/a/33350778/2480481.
Profile is made to allow you run test with certain personalization of the firefox, settings, extensions, etc, not for save it.
But yes, I miss too a parameter to make it "fixed" instead of temporal.

Related

Selenium won't open specific chrome profile python [duplicate]

This question already has answers here:
How to open a Chrome Profile through Python
(2 answers)
How to use Chrome Profile in Selenium Webdriver Python 3
(12 answers)
How to open the Default Chrome Profile through Selenium, ChromeDriver and GoogleChrome
(4 answers)
Closed 2 years ago.
I have a chrome profile (called Profile 1) which I would like to control with Selenium. Whenever I try to open that chrome profile, Chrome opens without my profile, like it was my very first time opening Chrome.
My code is the following:
options = Options()
options.add_argument("user-data-dir=C:\\Users\\Ákos\\AppData\\Local\\Google\\Chrome\\User Data\\Profile 1")
driver = webdriver.Chrome(executable_path="C:\\pythonScriptjeim\\chromedriver.exe", options=options,)
driver.get("https://www.google.com/")
Funny thing is if i delete Profile 1 from the end like this, Chrome opens with my default profile:
options.add_argument("user-data-dir=C:\\Users\\Ákos\\AppData\\Local\\Google\\Chrome\\User Data")
So my problem is, that anything written after User Data doesn't seem to have any effects on chrome.
Any suggestions on how I could open the profile i'd like to control?

How to use Python Selenium on existing browser? [duplicate]

This question already has answers here:
How can I reconnect to the browser opened by webdriver with selenium?
(4 answers)
Closed 2 years ago.
I'm new to Selenieum and still trying to understand how the different pieces work together. I am trying to automate some interaction tasks on an internal website using Python. However, I am trying to use the existing Chrome browser session AFTER I've authenticated with my username and password rather than launching a new browser. I'd like to start where my browser is currently and I'd also like to use a separate profile when launching chrome as to not pollute the default Chrome browser (not sure this is necessary). The driver is currently on a folder on my desktop and I also created a variable ChromeDriver location in my PATH environment variable on my Mac but I am not sure that is really necessary. I also created I've researched several similar post and found the code below on SO, but when I run it still opens a new browser and drops me at the login screen.
from selenium import webdriver
PATH = 'where chrome driver is located'
driver = webdriver.Chrome(PATH)
url = driver.command_executor._url
session_id = driver.session_id
driver = webdriver.Remote(command_executor=url,desired_capabilities={})
driver.close()
driver.session_id = session_id
driver.get("https://whereidliketobeafterlogin")
Based on this post here it looks like your answer may already be available.
I had a similar requirement but it was part of a larger application so i created a quick dialog box using the built in tkinter library to take a username and password so that Selenium could do the log in for me, that way my user data was never stored anywhere.
As far as using a separate profile than whats currently logged in your browser and all, when Selenium web driver starts up a new browser it functions as if it is in the incognito/private version, not retaining any of the login/session info unless specified through parameters.
Lastly, the PATH environment variable isnt entirely necessary, as long as you give filepath to the driver on your desktop when you create your webdriver object you are good.

Python and selenium: Force no download window [duplicate]

This question already has answers here:
Python: Unable to download with selenium in webpage
(5 answers)
Closed 4 years ago.
Using geckodriver and Firefox v63, I try to download a CSV file from a website without causing the download prompt to appear.
My code is:
from selenium import webdriver
profile = webdriver.FirefoxProfile()
profile.set_preference('browser.download.folderList', 2) # custom location
profile.set_preference('browser.download.manager.showWhenStarting', False)
profile.set_preference('browser.download.dir', '/Path/to/download')
profile.set_preference('browser.helperApps.neverAsk.saveToDisk', 'text/csv')
browser = webdriver.Firefox(profile, options=options)
browser.get('http://www.website.com')
download = browser.find_element_by_css_selector('selector')
download.click()
It does not work and I don't understand why. I don't get an error and the code executes, but it shows the Firefox download window and only safes the file if I click OK. I'd like to avoid clicking manually because I want to automate the task.
Open up FireFox and try this
Goto Preferences -> General
and then pick the folder you want to download to and uncheck the "always ask"
Give this a shot, good luck!

Launching Chromedriver using Selenium [duplicate]

This question already has answers here:
Can a website detect when you are using Selenium with chromedriver?
(25 answers)
Closed 4 years ago.
What options do I set for chromedriver so that the web server cannot tells the browser is manually launched or programming launched using Selenium?
Thanks,
The Webserver you try to access has no way of knowing how the browser has been launched. It can only detect (or rather, guess) that it's an automated browser when said browser shows atypical behavior for a human (e.g. makes loads of requests per seconds, clicks 2 things with no delay whatsoever). Therefor it doesn't matter how you launch the browser - just how you use it.

how to create a link element tag to about:config? [duplicate]

This question already has an answer here:
Anchor link to Firefox about:config?
(1 answer)
Closed 4 years ago.
I tried,
setup
element just shows up on the Firefox browser, but cannot open it (clicking won't work) or open it in a new tab.
Is there a way to create a link element to open up about:config page in Firefox using just HTML?
According to this it's imposible Anchor link to Firefox about:config?
right?
But, how about in Selenium with geckodriver?
I think this question answers your question: Anchor link to Firefox about:config?. Give it a try. Basically, you are not allowed to reference a local resource due to security issues (like the post says).
Sorry, it's not possible due to security concerns.
I'm not sure how useful this is, but if you can get the user to create a bookmark, it will work from a bookmark.

Categories