selenium 4.0.0b4: "Failed to open new tab - no browser is open"

Viewed 448

i have chrome and chromedriver - 91.0.4472.101, selenium python - 4.0.0b4

the following code, trying to open new tab via switch_to.new_window() fails, at that step, if i enable permanent user profile. commenting out the 2 culprit lines in the middle makes it work:

from selenium import webdriver
import time

options = webdriver.ChromeOptions()
options.add_argument('--start-maximized')

# these 2 options cause the 'Failed to open new tab..'
options.add_argument(r'user-data-dir=I:\tmp')
options.add_argument('--profile-directory=test')
# ----------------------------------------------

driver = webdriver.Chrome(options=options,
                          service_args=["--verbose", "--log-path=./qc1.log"])

driver.get("https://www.google.com/")
time.sleep(5)

driver.switch_to.new_window('tab')
time.sleep(5)

driver.quit()

the log says this:

[1623672502.083][INFO]: Done waiting for pending navigations. Status: ok [1623672502.084][INFO]: [81c25f6ce819bab36729f115b3f9537f] RESPONSE Navigate [1623672507.092][INFO]: [81c25f6ce819bab36729f115b3f9537f] COMMAND NewWindow {    "type": "tab" } [1623672507.092][INFO]: Waiting for pending navigations... [1623672507.092][DEBUG]: DevTools WebSocket Command: Runtime.evaluate (id=28) A2CB456B81426CD5FB300ED7408025D4 {   "expression": "1" } [1623672507.093][DEBUG]: DevTools WebSocket Response: Runtime.evaluate (id=28) A2CB456B81426CD5FB300ED7408025D4 {  "result": {
      "description": "1",
      "type": "number",
      "value": 1    } } [1623672507.093][INFO]: Done waiting for pending navigations. Status: ok [1623672507.093][INFO]: resolved localhost to ["::1","127.0.0.1"] [1623672507.093][DEBUG]: DevTools WebSocket Command: Browser.getWindowForTarget (id=1) browser {    "targetId": "A2CB456B81426CD5FB300ED7408025D4" } [1623672507.094][DEBUG]: DevTools WebSocket Response: Browser.getWindowForTarget (id=1) browser {    "bounds": {
      "height": 1010,
      "left": -8,
      "top": -8,
      "width": 1296,
      "windowState": "maximized"    },    "windowId": 1 } [1623672507.094][DEBUG]: DevTools WebSocket Command: Target.createTarget (id=2) browser {    "background": true,    "newWindow": false,    "url": "about:blank" } [1623672507.101][DEBUG]: DevTools WebSocket Response: Target.createTarget (id=2) browser {"code":-32000,"message":"Failed to open new tab - no browser is open"} [1623672507.101][DEBUG]: DevTools WebSocket Command: Runtime.evaluate (id=29) A2CB456B81426CD5FB300ED7408025D4 {    "expression": "1" } [1623672507.102][DEBUG]: DevTools WebSocket Response: Runtime.evaluate (id=29) A2CB456B81426CD5FB300ED7408025D4 {  "result": {
      "description": "1",
      "type": "number",
      "value": 1    } } [1623672507.102][INFO]: Waiting for pending navigations... [1623672507.102][DEBUG]: DevTools WebSocket Command: Runtime.evaluate (id=30) A2CB456B81426CD5FB300ED7408025D4 {    "expression": "1" } [1623672507.104][DEBUG]: DevTools WebSocket Response: Runtime.evaluate (id=30) A2CB456B81426CD5FB300ED7408025D4 {  "result": {
      "description": "1",
      "type": "number",
      "value": 1    } } [1623672507.104][INFO]: Done waiting for pending navigations. Status: ok [1623672507.104][INFO]: [81c25f6ce819bab36729f115b3f9537f] RESPONSE NewWindow ERROR unknown error: unhandled inspector error: {"code":-32000,"message":"Failed to open new tab - no browser is open"}   (Session info: chrome=91.0.4472.101)
0 Answers
Related