How to open a new window on a browser using Selenium WebDriver for python?

后端 未结 4 926
谎友^
谎友^ 2020-12-05 19:10

I am attempting to open a new tab OR a new window in a browser using selenium for python. It is of little importance if a new tab or new window is opened, it is only import

4条回答
  •  感动是毒
    2020-12-05 19:58

    How about you do something like this

    driver = webdriver.Firefox() #First FF window
    second_driver = webdriver.Firefox() #The new window you wanted to open
    

    Depending on which window you want to interact with, you send commands accordingly

    print driver.title #to interact with the first driver
    print second_driver.title #to interact with the second driver
    

    For all down voters:


    The OP asked for "it is only important that a second instance of the browser is opened.". This answer does not encompass ALL possible requirements of each and everyone's use cases. The other answers below may suit your particular need.

提交回复
热议问题