How to open multiple webpages in separate tabs within a browser using selenium-webdriver and python

后端 未结 1 2046
南笙
南笙 2020-11-28 16:35

I want to open mulitple local htmls within same browser window using Selenium Webdriver using Python. I have tried following in Jupyter notebook:

from seleni         


        
相关标签:
1条回答
  • 2020-11-28 16:40

    To open multiple URLs / webpages in seperate TABs within a browser you can use the following solution :

    • Code Block :

      from selenium import webdriver
      
      first_page = "http://www.google.com"
      second_page = "https://www.facebook.com/" 
      options = webdriver.ChromeOptions() 
      options.add_argument("start-maximized")
      options.add_argument('disable-infobars')
      driver=webdriver.Chrome(chrome_options=options, executable_path=r'C:\Utility\BrowserDrivers\chromedriver.exe')
      driver.get(first_page)
      driver.execute_script("window.open('" + second_page +"');")
      
    • Browser Snapshot :

    0 讨论(0)
提交回复
热议问题