How to connect to existing instance of firefox using selenium in django and how to pass these arguments

61 Views Asked by At

I want to login to a page manually in Firefox using selenium and use Django to connect to this existing Firefox browser and click on a link on this already opened page.

I did see that a marionette port can be useful for this process but I am not sure how to add these arguments in the driver class and also how to call it to connect to this manually opened browser to click on an element and open a new browser.

This is the driver class:

class FirefoxDriver(webdriver.Firefox, CustomDriverBase):
    def __init__(self, *args, **kwargs):
        firefox_binary = FirefoxBinary(settings.FIREFOX_BINARY_PATH)
        super().__init__(firefox_binary=firefox_binary, *args, **kwargs)

class BasePage:
    def __init__(self, driver: WebDriver):
        self.driver = driver

    def get_url(self, url: str) -> NoReturn:
        self.delay()
        self.driver.get(url=url)

class HomePage(BasePage):
    url = 'any url which can be logged into'

    def get(self) -> NoReturn:
        self.get_url(url=self.url)
        self.click_button(locator_cls=locators.HomePageLocators, locator_name='submit')

I want to login to a webpage manually in marionette port(and keep it open all the time) and in the HomePage class , I want to click on a link which has been opened on the marionette port and continue the process.

I am not able to understand where the arguments for marionette port needs to be specified and how to click on a link from that browser and incorporate it into the HomePage class as if that link is the homepage in the HomePage class

0

There are 0 best solutions below