from splinter import Browser
with Browser() as browser:
browser.visit('https://google.com/')
browser.visit('http://www.bing.com/')
browser.windows[0]
browser.windows[1]
如何在python分裂和更改选项卡中打开两个选项卡?
import time
from splinter import Browser
from selenium.webdriver.common.keys import Keys
with Browser() as browser:
# visit fst url
browser.visit('https://google.com/')
# open new tab
browser.driver.find_element_by_tag_name('body').send_keys(Keys.CONTROL + 't')
# visit second url
browser.visit('https://www.bing.com/')
# switching between tabs
browser.driver.find_element_by_tag_name('body').send_keys(Keys.CONTROL + Keys.TAB)
time.sleep(1)
browser.driver.find_element_by_tag_name('body').send_keys(Keys.CONTROL + Keys.SHIFT + Keys.TAB)
time.sleep(1)
browser.driver.find_element_by_tag_name('body').send_keys(Keys.CONTROL + Keys.TAB)
# visit third url in fst tab
browser.visit('https://stackoverflow.com/')