GithubHelp home page GithubHelp logo

Comments (9)

SheldonPatnett avatar SheldonPatnett commented on June 26, 2024 1

P.S. Is there a way I can buy you a coffee?

from tor-browser-selenium.

gunesacar avatar gunesacar commented on June 26, 2024

Your code looks right. See also the test code in test_should_install_custom_extension for reference:

with TBDriverFixture(TBB_PATH, extensions=[xpi_path]) as driver:
assert 'Borderify' in self.get_list_of_installed_addons(driver)

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.

SheldonPatnett avatar SheldonPatnett commented on June 26, 2024

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.

SheldonPatnett avatar SheldonPatnett commented on June 26, 2024

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.

SheldonPatnett avatar SheldonPatnett commented on June 26, 2024

`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.

gunesacar avatar gunesacar commented on June 26, 2024

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.

SheldonPatnett avatar SheldonPatnett commented on June 26, 2024

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.

SheldonPatnett avatar SheldonPatnett commented on June 26, 2024

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.

gunesacar avatar gunesacar commented on June 26, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.