Selenium Remote Webdriver with remote profile
Asked Answered
M

2

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?_)
        )
Mccomb answered 27/10, 2016 at 18:38 Comment(4)
Yes, you can. Did you try with disabling the firewall in your server?Incoherent
@Incoherent The firewall is forwarding the port to the server. Maybe I wasn't clear in my question. I've edited it.Inoperative
Did you create FireFox profile in your machine? If not please refer toolsqa.com/selenium-webdriver/custom-firefox-profile and add the profile to your code an then tryIncoherent
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.Inoperative
T
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.

Thurmanthurmann answered 12/11, 2016 at 21:44 Comment(4)
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?Inoperative
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.Hime
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) "Hime
@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.Inoperative
T
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:

Tannertannery answered 16/4, 2021 at 19:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.