Selenium Firefox webdriverdriver: extension (IETab v2) configurations - Python - python

Python v2.7 and Selenium I guess it is v2.49 (current last version)
I was able to add the extension (IETab V2):
profile=FirefoxProfile(profilePath)
profile.add_extension(extension=extensionPath)
driver = webdriver.Firefox(firefox_profile=profile)
Im normally able to configure the extension (when Im not using the browser through webdriver) and the configurations are there everytime I open the browser (Im setting the websites to be opened with IETab). However, when I open the browser through webdriver although the extension is there I lose the configurations.
Any idea how to keep the extensions configs when loading the browser through webdriver?
Thanks.

Most firefox extensions keep their settings in the profile settings. You can access those by typing about:config in your url bar. Find the corresponding settings and set them manually on your FirefoxProfile instance. If there's too many settings, search for prefs.js in your firefox profile directory. That's a snapshot of the settings in plain text from the last time you closed the browser.

Related

How to use normal chrome completely without chromedriver selenium python not duplicate

How to use normal chrome completely without chromedriver selenium python not duplicate.
I am using python 3.8.8,os is windows 7 ultimate with pycharm as
IDE and chrome version is around 96. and my problem is that whenever I use my python script to scrape a website it uses chromedriver and when I specify what's given below:
options = Options ()
options.add_argument(r"user-data-dir=my chrome path which is not Executable instead the user data")
#this works but when opening chrome it shows "browser is controlled by automated software" and changing it to normal chrome. Exe won't work
Sure it uses normal chrome with my credentials but it still needs chromedriver to work and when I delete the chromedriver it throw an error and when I go into selenium source code in a file called site.py(or sites.py) which I changed the variable self. executable to chrome.exe path and it worked and it won't show the message browser is controlled by automated software but it won't do anything , it is just stuck there and what I want to do is use chrome as the browser to scrape without chromedriver in my pc is it possible? If yes please tell me how should I go on to do it and you can ask for further Clarification and details and Thanks in advance
By default, selenium is detected as an automated software and is flagged by most websites, and the flag is unable to be removed. There are, however, external libraries that can be installed that can remove the flag.
There are options here to try to get around the default flag and hide the fact the browser is automated.
Edit
I understand the question further, and see that you want a more portable chrome option. Chrome driver is a very specific program controlled by selenium and must be used. There is no substitute. You can use Firefox driver or internet explorer, but a webdriver must be used (hence the name driver for driving the main browser). When you specify the directory for the Chrome binary, you aren’t removing the middleman of the chromedriver, only Specifying where chrome driver needs to look!
Using Selenium you won't be able to initiate/spawn a new Browsing Context i.e. Chrome Browser session without the ChromeDriver.
The Parts and Pieces
As a minimum requirement, the WebDriver i.e the ChromeDriver talks to a browser through a driver and the communication is two way:
WebDriver passes commands to the browser through the driver
Receives information back via the same route.
Hence using ChromeDriver is a mandatory requirement.

How do I click buttons on App which is installed on machine but not a Windows application. App opens a chrome instance (not default Chrome browser)

How do I navigate and click buttons on an already open Chrome instance/window. So the scenario is, that an application named "ApplicationNAME" is installed on my Windows machine, but its not a Windows application, because when I run the application it is only opening a chrome instance (not the default Chrome browser). I am also able to see the Developers Tool of chrome, and I am able to inspect the elements which means a chrome instance is opened.
So the idea is to automate this Application using Python and Selenium. I am open for alternate suggestions too. Thank you!
I have used the below Python (3.7.3) code but it doesn't help, because it rather opens another Chrome browser or navigate to already open Chrome window rather than going into the desired "ApplicationNAME" chrome instance.
from pywinauto.application import Application, WindowSpecification
import time
import requests
import selenium
from selenium import webdriver
app = Application().start(cmd_line=u'"C:\\Program Files (x86)\\ApplicationName.exe" ')
chromewidgetwin = app[u'ApplicationName']
chromewidgetwin.wait('ready')
chromerenderwidgethosthwnd = chromewidgetwin[u'Chrome Legacy Window']
chromerenderwidgethosthwnd.click()
Driver = webdriver.Chrome ("C:\\chromedriver.exe")
Driver.switch_to_window('ApplicationName')

Extensions not loading in Chrome driver Profiles Selenium

I am wanting to use Profiles in Selenium Chrome.
I have tried:
options = webdriver.ChromeOptions()
options.add_argument("user-data-dir=C:\\Users\\Bain3\\AppData\\Local\\Google\\Chrome\\User Data\\Profile 1") #Path to your chrome profile
w = webdriver.Chrome(chrome_options=options)
I do not believe the profile is being loaded correctly as the extensions are not being loaded with it and instead gives me normal chrome with chrome automation extension. I have done this in geckodriver with no issues.
My next question is, as I want to use profiles in Selenium chromedriver. How do I remove the profiles icon and images from Chrome as I often use Chrome by default. It seems pointless to have these icons when I already have names for the profiles in the shortcuts.
I tried:
start "" "c:\program files (x86)\google\chrome\application\chrome.exe" --new-window --disable-new-avatar-menu
as well as navigating through chrome://flags/
Any ideas on why extensions are not being loaded with profiles and if the profile button in chrome can be disabled as well as the icons?
Here's an image of the icons and profiles icon that I could not get to be disabled. https://ibb.co/hS4N45 .
i had the same issue then i used the extension crx file to add it on launch by using :
options.add_extension("idmgcext.crx")
the crx file is in the same folder as the script or provide full path if in another folder you can get chrome extension crx file using this site: https://chrome-extension-downloader.com/

Python automatic web test tool with selenium: download file in firefox

I have a web test tool developed with python using selenium 3 api. I run it in Firefox. There's a part in the website permits to download a tar.gz file. I want that the test tool download the file in a specified local folder without displaying popup download window.
So in init step and before opening the browser I added some preferences to the profile of Firefox like that:
profile = webdriver.FirefoxProfile()
profile.set_preference('browser.helperApps.neverAsk.saveToDisk', 'application/x-gzip')
profile.set_preference("browser.download.folderList",2)
profile.set_preference("browser.helperApps.alwaysAsk.force", False)
profile.set_preference("browser.download.dir", downloadPath)
profile.set_preference("browser.download.manager.showWhenStarting", False)
But this code doesn't prevent displaying the download window and always ask me where to download the file.
In addition if check preferences of Firefox while test running I find that Downloads setting is save to Downloads folder not like what is set in browser.download.dir parameter.
Is there any idea to fixe this problem?
Development environment: Python 2.7, selenium 3.0.1, Firefox 49

Selenium: How to work with already opened web application in Chrome

I'm looking for a solution that could help me out automating the already opened application in Chrome web browser using Selenium and Python web driver. The issue is that the application is super secured, and if it is opened in incognito mode as Selenium tries to do, it sends special code on my phone. This defeats the whole purpose. Can someone provide a hacky way or any other work around/open source tool to automate the application.
Selenium doesn't start Chrome in incognito mode, It just creates a new and fresh profile in the temp folder. You could force Selenium to use the default profile or you could launch Chrome with the debug port opened and the let Selenium connect to it. There is also a third way which is to preinstall the webdriver extension in Chrome. These are the only ways I've encountered to automate Chrome with Selenium.

Categories