Open and close new tab with Selenium WebDriver in OS X

前端 未结 5 570
北恋
北恋 2021-01-11 16:23

I\'m using the Firefox Webdriver in Python 2.7 on Windows to simulate opening (Ctrl+t) and closing (Ctrl + w) a new tab.

5条回答
  •  萌比男神i
    2021-01-11 16:55

    Open new tab:

    browser.execute_script("window.open('"+your url+"', '_blank')")
    

    Switch to new tab:

    browser.switch_to.window(windows[1])
    

提交回复
热议问题