在python中,我创建了4个进程来同时打开多个选项卡但是选项卡按顺序打开但不是小部件。
代码是:
from selenium import webdriver
from multiprocessing import Process
from selenium.webdriver.common.keys import Keys
def func1(driver):
driver.find_element_by_tag_name('body').send_keys(Keys.CONTROL + 't')
driver.switch_to.window(driver.window_handles[-1])
driver.get('http://www.rediff.com')
driver.implicitly_wait(20)
driver.get('http://yatra.com')
driver.implicitly_wait(50)
driver.get('http://makemytrip.com')
def func2(driver):
driver.find_element_by_tag_name('body').send_keys(Keys.CONTROL + 't')
driver.switch_to.window(driver.window_handles[-1])
driver.get('http://www.stackoverflow.com')
driver.implicitly_wait(10)
driver.get('http://www.facebook.com')
driver.refresh()
def func3(driver):
driver.find_element_by_tag_name('body').send_keys(Keys.CONTROL + 't')
driver.switch_to.window(driver.window_handles[-1])
driver.get('http://www.yahoo.com')
driver.refresh()
if __name__=='__main__':
driver = webdriver.Chrome()
driver.get('https://www.google.com')
p1 = Process(target = func1(driver))
p1.start()
p2 = Process(target = func2(driver))
p2.start()
p3= Process(target=func3(driver))
p3.start()
是什么原因?如何同时打开3个标签并将不同的任务分配给不同的标签?