splinter icon indicating copy to clipboard operation
splinter copied to clipboard

Not able to update the firefox preference

Open HinaSharma1 opened this issue 5 years ago • 3 comments

Hi Team ,

Am using an automation framework based on python , selenium and splinter. Usecase : I have an xpath - where the locator is href. When I find that xpath on my ui, i need to click it so that it opens up in a new tab. Problem : For firefox, the xpath with the href link opens up in a new window. Which is not as expected.

What have I tried : I tried to update the preference - ""browser.link.open_newwindow": 3

firefox_options= Options() firefox.set_preferences(browser.link.open_newwindow":,3)

The above code is updated in file firefox.py. I was able to update it locally and it runs successfully. HOwever, I do not get permisson to push to my git branch.

Please confirm how can we make this work. I understand this will require a change in LIbrary ..but not sure how to do that. SInce, we don't tha required access right.

HinaSharma1 avatar Sep 07 '21 20:09 HinaSharma1

Have you tried something like this in your test script when instantiating the browser?:

class TestSysadminTracker(unittest.TestCase):

    @classmethod
    def setUpClass(cls):
            ...
           profile_preferences = {
                "browser.link.open_newwindow": 2
                }

            cls.browser = Browser('firefox',
                                  profile_preferences=profile_preferences,
                                  headless=True, fullscreen=True)
            cls.browser.driver.set_window_size(1280,1696)

when you set up your test class?

rouilj avatar Oct 11 '21 02:10 rouilj

As of version 0.16.0, the Firefox browser now supports sending an Options object to the driver. eg:

my_options = Options()
browser = Browser(options=my_options)

javascript-error avatar Oct 17 '21 22:10 javascript-error

great! Thankyou team! was able to make it work with the above steps.

HinaSharma1 avatar Oct 18 '21 04:10 HinaSharma1