8

Is it possible to open a Selenium Remote Webdriver with a specific remote profile (not temporary) in the server?

I have only been able to pass a browser_profile from the client. If I instantiate the class without browser_profile Selenium creates a new temporary profile in the server.

from selenium import webdriver

class Remote(webdriver.Remote):
    def __init__(self, **kwargs):
        capabilities = {_**whatever_}

        super().__init__(
            command_executor='http://HOST:PORT/wd/hub',
            desired_capabilities=capabilities.copy(),
            browser_profile=webdriver.FirefoxProfile(_what?_)
        )
Nuno André
  • 4,739
  • 1
  • 33
  • 46
  • Yes, you can. Did you try with disabling the firewall in your server? – Prabhakar Nov 06 '16 at 02:43
  • @Prabhakar The firewall is forwarding the port to the server. Maybe I wasn't clear in my question. I've edited it. – Nuno André Nov 06 '16 at 06:05
  • Did you create FireFox profile in your machine? If not please refer http://toolsqa.com/selenium-webdriver/custom-firefox-profile/ and add the profile to your code an then try – Prabhakar Nov 07 '16 at 08:14
  • I can pass profiles _from_ my machine to the server and create temporary profiles _in_ the server. But I want to use profiles _of_ the server. – Nuno André Nov 08 '16 at 02:23

2 Answers2

3

No, it is not possible to pass path of remote profile in case of remote webdriver. The reason being that all remote communication is handled by command executor. Where as browser profile is dealing with local file system only. Though default profile can be configured on server.

Community
  • 1
  • 1
Falloutcoder
  • 991
  • 6
  • 19
  • But this parameter creates a copy of the profile, it doesn't use the actual profile. I'd also tried with `-browserSessionReuse` without success. Is there any way to enable session persistance between tests? – Nuno André Nov 18 '16 at 14:47
  • There's a way to use A remote profile, and another hacky way to have multiple profiles. What I didn't accomplish yet is to be able to pass remote profile path throuth options nor capabilities nor options.to_capabilities(). So, I've ended up with a real Firefox, with a custom -P profile, with -marionette enabled, then launching geckodriver with full set of flags, -marionete--port 2828, --connect-existing, etc. The hacky way to have multiple profiles is to launch MANY instances of Firefox and geckodrivers using a set of profiles and ports. – m3nda Oct 20 '20 at 18:13
  • If you're insterested I could elaborate a proper answer with all I have. What I can't answer is "how to pass remote profile path with remote driver", but I can answer to "open a Selenium Remote Webdriver with a specific remote profile (not temporary) " – m3nda Oct 20 '20 at 18:16
  • @m3enda I ended up doing something similar and tunneling through socks. This question seems to keep getting hits, so if you want to elaborate an answer I'll be glad to accept it. – Nuno André Apr 17 '21 at 03:15
0

here's what I was looking for:

            fp = webdriver.FirefoxProfile()
            fp.set_preference("browser.startup.homepage_override.mstone", "ignore")
            fp.set_preference("focusmanager.testmode", True)
            fp.update_preferences()

            driver = webdriver.Remote(
                command_executor='http://127.0.0.1:4444/wd/hub',
                desired_capabilities={'browserName': 'firefox', 'javascriptEnabled': True},
                browser_profile=fp
            )

reference:

jmunsch
  • 22,771
  • 11
  • 93
  • 114