最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

python - How to connect firefox through existing opened browser? - Stack Overflow

programmeradmin1浏览0评论

I am using the below code to launch firefox browser, and then to connect to existing firefox browser

The problem is the control remains at firefox_driver = webdriver.Firefox(service=service, options=custom_firefox_options) until the driver gets timeout

The driver gets created as I can see firefox running with automation sign, the control get stuck and does not move forward

I want to connect to existing firefox browser as I am using some desktop automation that clicks on links that need to be open in existing selenium automated browsers, instead of a new window

def create_firefox_driver() -> webdriver:
    firefox_driver = None
    binary_path = 'C:\\Program Files\\Mozilla Firefox\\firefox.exe'
    command = [
        binary_path,
        '--marionette',
    ]
    subprocess.Popen(command, shell=False, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)

    custom_firefox_options = // some options
    executable_path = GeckoDriverManager().install()
    service = FirefoxService(
        executable_path=executable_path,
        service_args=['--marionette-port=2828', '--connect-existing']
    )
    firefox_driver = webdriver.Firefox(service=service, options=custom_firefox_options)
    return firefox_driver```
发布评论

评论列表(0)

  1. 暂无评论