My goal is to use Selenium to configure an extension in Firefox programmatically.
What I did is the following:
Load my default Firefox profile, so that my Selenium session has access to my extensions.
Use Selenium to navigate to the extension's configuration page (moz-extensions://*********************/options/)
Use selenium to automate the configuration process and save.
My only issue is that my changes are lost. That is, upon starting Firefox again (like a "normal" user), none of the changes I made are kept.
Is there a way to ensure that Selenium saves the changes to my profile?
Related
I want to build a simple web scraper using python selenium and deploy it on Heroku. I've already done the deployment process with chromedriver and chrome buildpacks and everything is working fine. But I still need to implement one thing. I want to use my local chrome profile so that I don't have to sign up into Google. This is working fine locally by using
options = webdriver.ChromeOptions()
options.add_argument(r"user-data-dir=C:\\Users\\user\\AppData\\Local\\Google\\Chrome\\User Data")
To access my chrome profile on Heroku I just uploaded it the whole folder in the same directory as the code. After the deployment I can access the folder under /app/User Data and can see all files. However if I pass
options.add_argument(r"user-data-dir=/app/User Data")
to the Driver, it doesn't load the profile and the login process fails. I tried to get more information by printing the source code of "chrome://version", but that's just an empty page.
Do you have any suggestion what I can try instead to get it working? Thank you!
If you just need to login you can use https://pypi.org/project/selenium-stealth/ to login. It is selenium but it doesn't get detected when signing in.
I want to make a python CLI for Wappalyzer (https://www.wappalyzer.com), but it is a browser plugin. The plugin identifies programs/frameworks running on a webpage, and I want to be able to use/get that information from a python script. While they do have a paid API, I was wondering if it is possible to use Selenium and the ChromeDriver to visit the page with a chrome extension, and then retrieve the data generated by Wappalyzer.
Is it possible to make a chromium extension that would expose an API to python selenium webdriver code? For example, I can make an extension with a background script, that would count the tabs with chrome.tabs.query, now I'd like to access that information from my python code using selenium webdriver.
I've been able to do this by querying background script from content script using chrome.extension.sendMessage, saving the data to window.localStorage, and fetching it to python with Command.GET_LOCAL_STORAGE_ITEM (or execute_script, doesn't matter), but is there a simpler way?
I've been researching this extensively but i have yet to even find a single topic about this specific question. I use python to access Selenium Webdriver, and have been disabling the extensions through python using the code
chrome_options.add_argument("--disable-extensions")
Recently though, i've wanted to load a custom profile, and that means custom extensions. is there a way to get rid of ONLY the automation extension?
ALSO, as a follow up curiosity, what even makes the chrome browser automatically start out with this extension loaded?
Thanks!
You can disable the Chrome Automation Extension by adding an experimental option to ChromeOptions like so:
ChromeOptions options = new ChromeOptions();
options.setExperimentalOption("useAutomationExtension", false);
I'm trying to download files using python 3. I use webbrowser.open_new(url) to open file locations. some files are downloaded automatically by chrome's downloader, and some are just opened in a chorme window. How can I choose between the options?
You cannot influence that, not with the Python webbrowser module.
What is downloaded and what is displayed in the browser is a preference set in the browser itself.
You could try and set those preferences using Selenium, see Set chrome.prefs with python binding for selenium in chromedriver. This is not going to be simple; you'll need to figure out the exact preference strings to alter. Perhaps the Chromium prefences list can be used as a guide there.
The Web server on which the file is hosted sends a header that suggests to the browser how it might handle the file, and the user's preferences hold some sway as well. You likely won't be able to override it easily.
You can avoid this by not using a Web browser from Python. urllib2 or better yet, the third-party requests module is a much easier way to talk to the Web.