Before I have used the code below, but it doesn't work anymore with firefox update.
from selenium.webdriver.firefox.firefox_profile import FirefoxProfile
firefoxProfile = FirefoxProfile()
firefoxProfile.set_preference('permissions.default.image', 2)
I also tried this one below, it seems good but is there a way to disable images without add-on or 3rd party tools?
from selenium import webdriver
firefox_profile = webdriver.FirefoxProfile()
firefox_profile.add_extension(folder_xpi_file_saved_in + "\\quickjava-2.0.6-fx.xpi")
firefox_profile.set_preference("thatoneguydotnet.QuickJava.startupStatus.Images", 2) ## Turns images off
Have you tried updating your selenium after the Firefox update?
eg :
sudo -H pip install --upgrade selenium
Related
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
options = Options()
options.add_argument("start-maximized")
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=options)
print("hello world")
running python 3.10 on linux ubuntu
I was trying to play aruond with selenium however any code that I write after defining the webdriver does not work.
it seems that the interpreter gets stuck after defining the webdriver. it opens the webdriver but only shows "data:," and nothing else and won't respond to any code written after.
Chromium support is limited on selenium in my experience.
Please look at the replies here which do mention chromium-driver and how to get it
sudo apt-get install chromium-chromedriver
Should get you chromium driver and they have some example code there that doesn't look too outdated.
I figured out the problem, I only had chromium installed on my computer and I assumed that the chromium drivers and the chrome drivers are the same thing(still can't find any refrence to the chromium drivers)
I'm started to learn python Selenium. I just downloaded by pip pip install python-selenium and started to write first lines and at this moment appeares
>>> from selenium import webdriver
>>> from selenium.webdriver.common.keys import Keys
>>> driver = webdriver.Firefox()
[WinError2] FileNotFoundError...
...
Then I tried it with Chrome but appeares the same thing. Who can solve this problem?
You do following things and check whether it works.
Upgrade python bindings using
pip install -U selenium
for chrome download the latest chrome driver "ChromeDriver 2.45"
and write the code
from selenium import webdriver
driver=webdriver.Chrome("Path of the Chromedriver" + "chromedriver.exe" )
Note that I edited the question.
How to activate blocking for ghostery extension in firefox through selenium python bindings? Note that by default the blocking in ghostery is disabled.
I am using selenium 3.6.0 and ghostery 7.3.3.7. Note that I am using selenium + pull request #4790 that allow the new web extensions, because the released version lack this feature.
I do the following:
from selenium import webdriver
fp = webdriver.FirefoxProfile()
fp.add_extension(extension=/home/nsarafij/ghostery-7.3.3.7.xpi)
driver = webdriver.Firefox(firefox_profile = fp)
Is it possible to activate blocking in ghostery through setting preferences?
fp.set_preferances(...)
Or, I have to do something different?
I am not sure i understand you correctly - you want to add Ghostery to Firefox right?
If so, this should work:
from selenium import webdriver
from selenium.webdriver.firefox.firefox_profile import FirefoxProfile
firefoxProfile = FirefoxProfile()
ghostery="PATH_TO_GHOSTERY_ADDON"
firefoxProfile.add_extension(ghostery)
firefoxProfile.update_preferences()
driver = webdriver.Firefox(firefoxProfile)
I am trying to learn about Selenium but I am not able to get even a simple program to test. Selenium webdriver seems to not be cooperating with Firefox and I am very frustrated, so I come to Stack Overflow for help.
For background, I use Python, can install with pip, and know command line.
I am on windows 10, firefox 48, and selenium webdriver 3 with python 3.5.2
Whenever I run the selenium test, (it opens a Firefox windows and the selenium website)
from selenium import webdriver
browser = webdriver.Firefox()
browser.get('http://www.seleniumhq.org')
I always get an error:
selenium.common.exceptions.WebDriverException: Message: Can't load the profile. Profile Dir: C:\ ... \AppData\Local\Temp\tmp68m5rtwt If you specified a log_file in the FirefoxBinary constructor, check it for details
It also opens a firefox window and has the link of about:blank&utm_content=firstrun(not a valid url)
I have looked across the internet for a similar situation, but nothing really close. I also tried many tutorials and made sure that I installed selenium the right way. I noticed that firefox was recently updated, but I am not sure if this has any effect.
I would appreciate any help for this, and instructions for what I should do.
Firefox 48+ doesn't support webdriver.Firefox().
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
caps = DesiredCapabilities.FIREFOX
caps["marionette"] = True
caps["binary"] = "path/to/your/firefox"
browser = webdriver.Firefox(capabilities=caps)
browser.get('http://www.seleniumhq.org')
This is what I was trying
1. download geckodriver.https://github.com/mozilla/geckodriver/releases. v.0.10.0is for selenium 3(beta).
2. add PATH your geckodriver.
4. rename it to wires
5. restart shell
6. check the version
$ wires --version
7. and run above the code.
I implemented below code to check selenium, but it get stuck, firefox window is not opened and nothing of error appears. print line is not executed.
from selenium import webdriver
driver = webdriver.Firefox()
driver.get("http://www.python.org")
print 'aaa'
driver.close()
I using 2.7.0 Selenium version and 44.0.2 firefox version. any idea what can be wrong here?
Your selenium is too old for the firefox 44, upgrade:
pip install --upgrade selenium