DevTools listening on ws://127.0.0.1:57671/devtools/browser/8a586f7c-5f2c-4d10-8174-7a7bf50e49b5 with Selenium and Python
H

5

1

I am using python + selenium for web browser automation and getting this error.

DevTools listening on ws://127.0.0.1:57671/devtools/browser/8a586f7c-5f2c-4d10-8174-7a7bf50e49b5
[5096:1196:0909/183254.362:ERROR:mf_helpers.cc(14)] Error in dxva_video_decode_accelerator_win.cc on line 517

The problem arises when the program reaches this part of code:-

def send_comments(driver):
    add_comments = driver.find_elements_by_class_name('add') 
    comments = driver.find_elements_by_xpath("//form[@class='addCommentexpand']//textarea[contains(@placeholder,'Add a comment')]") 
    submit_comments = driver.find_elements_by_xpath("//button[text()='Comment']")  
    i = 0
    for add, comment, submit in zip(add_comments, comments, submit_comments):
        print("comment begins")
        add.click()
        print("+add comment clicked")
        comment.click()
        print("comment textbox clicked")
        comment.send_comments("Amazing Art")
        print("text typed")
        submit.click()
        print("comment submited")
        i += 1
        if i > 5:
            driver.close()

send_comments(driver)

Its also not logging in console. Can anyone tell whats the problem?

Hausmann answered 9/9, 2018 at 14:44 Comment(0)
L
2

DevTools listening on ws://127.0.0.1:9222/devtools/browser/

@AndreaCardaci in the documentation Load a URL in a separate context mentions that when using Google Chrome in Headless Mode:

The usual example code is run in a new disposable tab in a separated context (think of it as incognito profiles) each time.

As inorder to fetch the browser version since Chrome 62 the browser target URL is generated at runtime and can be obtained via the /json/version endpoint and fallback to /devtools/browser if not present.

Here is the relevant code:

const CDP = require('chrome-remote-interface');

async function doInNewContext(action) {
    // fetch the browser version (since Chrome 62 the browser target URL is
    // generated at runtime and can be obtained via the '/json/version'
    // endpoint, fallback to '/devtools/browser' if not present)
    const {webSocketDebuggerUrl} = await CDP.Version();
    // connect to the DevTools special target
    const browser = await CDP({
        target: webSocketDebuggerUrl || 'ws://localhost:9222/devtools/browser'
    });
    // create a new context
    const {Target} = browser;
    const {browserContextId} = await Target.createBrowserContext();
    const {targetId} = await Target.createTarget({
        url: 'about:blank',
        browserContextId
    });
    // connct to the new context
    const client = await CDP({target: targetId});
    // perform user actions on it
    try {
        await action(client);
    } finally {
        // cleanup
        await Target.closeTarget({targetId});
        await browser.close();
    }
}

// this basically is the usual example
async function example(client) {
    // extract domains
    const {Network, Page} = client;
    // setup handlers
    Network.requestWillBeSent((params) => {
        console.log(params.request.url);
    });
    // enable events then start!
    await Promise.all([Network.enable(), Page.enable()]);
    await Page.navigate({url: 'https://github.com'});
    await Page.loadEventFired();
}

doInNewContext(example);

Moreover as per Obtain the browser target URL (ws://localhost:9222/devtools/browser/...) programmatically the endpoint is available over http://127.0.0.1:9222/json/version in a webSocketDebuggerUrl field. So alternatively, if you are starting chrome with the option --remote-debugging-port=0, both port and endpoint are written to the DevToolsAcivePort file in browser profile folder.

Conclusion

This error doesn't impact your @Test and you can ignore the error for the time being.

Lott answered 10/9, 2018 at 12:14 Comment(3)
so i just add that code in the beginning of my programHausmann
@SultanMorbiwala Nopes, I have added the code which is being used to initialize the new disposable tab in a separated context for your reference. This error basically have no impact on your tests.Lott
@SultanMorbiwala Glad to be able to help you. Upvote the answer if this/any answer is/was helpful to you for the benefit of the future readers.Lott
A
0

Based on Chanticleer in hide chromeDriver console in python

In your Python folder, find and edit this file:

Lib\site-packages\selenium\webdriver\common\services.py

Edit the Start() function by adding the creation flags this way: creationflags=CREATE_NO_WINDOW

from win32process import CREATE_NO_WINDOW

def start(self):
    """
    Starts the Service.

    :Exceptions:
     - WebDriverException : Raised either when it can't start the service
       or when it can't connect to the service
    """
    try:
        cmd = [self.path]
        cmd.extend(self.command_line_args())
        self.process = subprocess.Popen(cmd, env=self.env,
                                        close_fds=platform.system() != 'Windows',
                                        stdout=self.log_file, stderr=self.log_file, creationflags=CREATE_NO_WINDOW)
    except TypeError:
        raise

It works perfectly for me using python3.7 and selenium 3.141.0

Anatomist answered 25/3, 2019 at 12:33 Comment(0)
P
0

For others who cannot modify the packages source code (because it needs to work after pip install!!), thanks to @Denis, this actually worked for me:

chrome_options.add_argument("--log-level=3")

It removed the annyoing JQMITIGATE log..

(I can't comment or anything, that's why I'm writing this answer..)

Philpot answered 19/1, 2022 at 12:8 Comment(0)
C
-1

Try this:

options = webdriver.ChromeOptions()
options.add_experimental_option('excludeSwitches', ['enable-logging'])
Cleland answered 21/1, 2021 at 10:12 Comment(0)
N
-1

This is work:

import warnings
warnings.filterwarnings("ignore", category=DeprecationWarning) 
...
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("--log-level=3")
browser = webdriver.Chrome(chromedriver_path, chrome_options=chrome_options)
Naze answered 5/5, 2021 at 12:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.