Comments (9)
P.S. Is there a way I can buy you a coffee?
from tor-browser-selenium.
Your code looks right. See also the test code in test_should_install_custom_extension
for reference:
tor-browser-selenium/tbselenium/test/test_addons.py
Lines 48 to 49 in 462b027
If the problem persists, please check whether the options
or pref_dict
is interfering, and share the error message you get, if any.
from tor-browser-selenium.
Thank you for the speedy reply! The TBB_PATH used to launch the browser doesn't work, it says it needs proper path or binarary.. In the test.
In production I use 'workers' folder which has a subfolder of Browser which the current TOR browser bundle.
from tor-browser-selenium.
Sorry for not including my current unit test, please find it below
`import unittest
from os.path import dirname, realpath, join
from tbselenium.test.fixtures import TBDriverFixture
from tbselenium.test.test_addons import TBAddonsTest
from xvfbwrapper import Xvfb
vdisplay = Xvfb(width=1920, height=1080, colordepth=24)
vdisplay.start()
def start_tbselenium_with_adblock():
TBB_PATH = '/DEU/workers' # Replace with the actual TBB path
xpi_path = '/DEU/workers/Browser/adblock_plus-3.17.xpi'
with TBDriverFixture(TBB_PATH, extensions=[xpi_path]) as driver:
addons_test = TBAddonsTest()
assert 'Adblock Plus' in addons_test.get_list_of_installed_addons(driver)
# Run other test methods from TBAddonsTest if needed
if name == "main":
start_tbselenium_with_adblock()`
addons_test.get_list_of_installed_addons(driver)
throws the following exception
*** selenium.common.exceptions.WebDriverException: Message: Failed to extract web element from Marionette response
from tor-browser-selenium.
`from xvfbwrapper import Xvfb
vdisplay = Xvfb(width=1920, height=1080, colordepth=24)
vdisplay.start()
from os.path import dirname, realpath, join
from tbselenium.test.fixtures import TBDriverFixture
from tbselenium.test.test_addons import TBAddonsTest
import traceback
class CustomTBAddonsTest(TBAddonsTest):
def init(self):
super().init()
self.TBB_PATH = 'workers'
def test_should_install_custom_extension(self):
try:
with TBDriverFixture(self.TBB_PATH, extensions=['workers/Browser/adblock_plus-3.17.xpi']) as driver:
import ipdb ; ipdb.set_trace()
assert 'Borderify' in self.get_list_of_installed_addons(driver)
except Exception as e:
print("Error occurred during test execution:")
print(traceback.format_exc())
test = CustomTBAddonsTest()
test.test_should_install_custom_extension()
`
Sorry, I wasn't instancing the class properly in my previous post. I'm able to do things like driver.get("https://google.com") at the breakpoint but when I call the self.get_list_of_installed_addons(driver) method I'm getting *** selenium.common.exceptions.WebDriverException: Message: Failed to extract web element from Marionette response
from tor-browser-selenium.
It's hard to understand the code due to formatting issues, but if you can load a page via driver.get
but you get an error for get_list_of_installed_addons
, I'd recommend updating geckodriver
to 0.31.0 and selenium
to latest.
from tor-browser-selenium.
I'm deeply sorry about the confusion. I really should learn Github formatting!
from xvfbwrapper import Xvfb
vdisplay = Xvfb(width=1920, height=1080, colordepth=24)
vdisplay.start()
from os.path import dirname, realpath, join
from tbselenium.test.fixtures import TBDriverFixture
from tbselenium.test.test_addons import TBAddonsTest
import traceback
from tbselenium.tbdriver import TorBrowserDriver
from selenium.webdriver.common.by import By
TBB_PATH = 'workers'
extensions = ['workers/Browser/adblock_plus-3.17.xpi', '/DEU/workers/Browser/ublock_origin-1.49.2.xpi']
driver = TorBrowserDriver("/DEU/workers", extensions=extensions)
driver.get("about:addons")
driver.save_screenshot('test.png')
Using snippets from your unit test, I was able to take a screenshot. The load_url method doesn't exists for some reason. The screenshot does indeed show the adblockers are installed, but I'm getting a low score on https://adblock-tester.com/ vs when I manually run it locally with extensions installed. This is most certainly out of scope for the this repository.
Thank you very much for you help :) Feel free to mark this issue as solved.
from tor-browser-selenium.
Maybe the extensions aren't able to run in the context of a private window? Which I believe TOR browsers launches in, by default?
from tor-browser-selenium.
Hi @SheldonPatnett , glad you have it worked.
Allowing extensions to run on Private windows is a good idea.
Trying them one by one may be another...
You can also compare the (adblocker) rulesets used in the browsers to see if the (ruleset) versions match or not.
But, as you said, this issue is likely not related to tor-browser-selenium. So I'm closing.
from tor-browser-selenium.
Related Issues (20)
- почему не поддерживает виндовс и когда будет если будет HOT 1
- Message: Process unexpectedly closed with status 1 HOT 2
- Error with the new version of selenium or python-selenium HOT 2
- Compatible versions - WebDriverException Message: Process unexpectedly closed with status 255 HOT 9
- Use custom tor build HOT 1
- Message: Process unexpectedly closed with status 1 HOT 2
- Initialization error with Selenium 4.11 HOT 2
- Help me on Mac gecko driver HOT 1
- error with selenium 4.11 and driver HOT 1
- Trouble with tor binary HOT 14
- Cannot install tbselenium HOT 4
- Invalid firefox binary HOT 2
- Process unexpectedly closed with status 255 HOT 1
- Headless mode fails since Selenium 4.12.0 HOT 1
- pip install error HOT 1
- selenium.common.exceptions.WebDriverException: Message: Process unexpectedly closed with status 255 HOT 1
- Can't launch Tor Browser with the specified ExitNodes
- allow read-only tbb_path/Browser/
- change tor circuit while torbrowser is running
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tor-browser-selenium.