How to Connect the Chronium DebuggingAddress for Python Selenium

은철 이 1 Reputation point
2020-12-11T00:05:30.18+00:00

Hello
I first turned on the Edge Browser with the code below and tried to connect Selenium to an open edge, but it seems that the DebugAddress of Selenium was not applied.

from msedge.selenium_tools import Edge, EdgeOptions


        subprocess.Popen('start msedge.exe  --remote-debugging-port=9222 --user-data-dir="C:/EdgeTEMP" ', shell=True)
        options = EdgeOptions()
        capabilities = options.to_capabilities()
        options.use_chromium = True
        options.add_argument('disable-infobars')
        options.set_capability("debuggerAddress", "127.0.0.1:9222")
        driver = webdriver.Edge(executable_path = "./msedgedriver.exe", capabilities=capabilities)

Please tell me how to use Selenium for an Edge Browser that is already open.

Microsoft Edge
Microsoft Edge
A Microsoft cross-platform web browser that provides privacy, learning, and accessibility tools.
2,342 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Deepak-MSFT 2,201 Reputation points Microsoft Vendor
    2020-12-11T07:55:00.063+00:00

    @은철 이 ,

    I suggest you try to refer to the steps below may help you to connect the Edge Chromium debugger address using Selenium Python code.

    1) First I start the Edge Chromium browser instance from the command prompt (run as Administrator) using the command below.
    msedge.exe -remote-debugging-port=9222 --user-data-dir="<Your_User_Profile_path_here...>"

    2) Run the below python code to connect the Edge browser instance.

         from msedge.selenium_tools import Edge, EdgeOptions  
         options = EdgeOptions()  
         options.use_chromium = True  
         options.add_experimental_option("debuggerAddress", "127.0.0.1:9222")  
         driver = Edge(executable_path = r"Edge_driver_path_here...\msedgedriver.exe", options= options)  
         driver.get("https://Your_site_URL_here...")  
    

    Output:

    ![47342-181.gif

    Note: I made this test with the MS Edge Version 87.0.664.57 (Official Build) (64-bit)


    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.