📅  最后修改于: 2022-03-11 14:46:47.302000             🧑  作者: Mango
#import from selenium driver
from selenium import webdriver
#import from use of Key actions && Action chains (commands) from selenium driver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.by import By
import time
#designate each URL to be opened
url_1 = 'https://www.google.com/'
url_2 = 'https://github.com/'
url_3 = 'https://www.kaggle.com/'
#designate webdriver as chrome
driver = webdriver.Chrome()
#open 1st URL in first tab
driver.get(url_1)
#wait
driver.implicitly_wait(15)
#open new window (tab 2) and switch over to it
driver.execute_script("window.open('');")
driver.switch_to.window(driver.window_handles[1])
#open 2nd URL in current tab
driver.get(url_2)
#wait
driver.implicitly_wait(15)
#open new window (tab 3) and switch over to it
driver.execute_script("window.open('');")
driver.switch_to.window(driver.window_handles[2])
#open 3rd URL in current tab
driver.get(url_3)
#wait
driver.implicitly_wait(15)