When selenium opens multiple chromedriver objects at the same time, unknown error: DevToolsActivePort file doesn't exist

The first one is normal, and the second one prompts (unknown error: DevToolsActivePort file doesn't exist)

According to the solution introduced by StackOverflow plus 

options.add_argument("--remote-debugging-port=9292")

No longer report unknown error: DevToolsActivePort file doesn't exist, but when driver.get(url) is all opened on the first webdriver, all subsequent windows are always blank pages.

After a round of code shielding and debugging line by line, it was found that the problem lies in the value of user-data-dir

options.add_argument(r'--user-data-dir={}'.format(data_dir))

If multiple webdrivers share the same user-data-dir, an error will be reported even if different profile-directories are specified.

If multiple webdrivers are opened at the same time, user-data-dir cannot be shared.

Note: When not sharing user-data-dir, be sure to delete options.add_argument("--remote-debugging-port=9292")

Guess you like

Origin blog.csdn.net/bigcarp/article/details/128227215