0

I was trying to open another tab using undetected chrome driver in python. I found that when I use the javascript way chrome blocks my pop-up. I can't figure out what I'm doing wrong. Here's my code.

options = webdriver.ChromeOptions()
options.add_argument('--disable-popup-blocking')
if __name__ == '__main__':
      chrome = uc.Chrome(options=options)  
      time.sleep(1)
      chrome.get("https://www.google.com")
      chrome.execute_script("window.open('https://google.com','_blank')")

1 Answers1

0

You need to do some action or use sleep after opening the new tab, otherwise the browser will close immediately after opening a new tab. Try adding time.sleep(30) to the end of your code.

  • the questioner already added this parameter – 53RT Sep 27 '22 at 11:32
  • I see, I forgot about it. The problem may be that if there is no **action** or `sleep` and after opening a new tab the chrome exits - new tab did open but the OP didn't see it. I have edited my answer – Viliam Popovec Sep 27 '22 at 17:47