I'm trying to open site in new tab, code:
from selenium import webdriver
import time
driver = webdriver.Chrome('/home/metulburr/chromedriver')
# List of opened tabs
print('before sleeping', window_handles)
# Open a new window
# This does not change focus to the new window for the
driver.driver.execute_script("window.open('');")
# Switch to the last window
driver.switch_to.window(driver.window_handles[-1])
print('after sleeping', window_handles)
But I'm failing because not all tabs are loaded
OUTPUT:
# Not all opened tabs
`before sleeping: ['CDwindow-112051A6FC23C19FA18D321731625FC9']`
# All opened tabs
`after sleeping: ['CDwindow-112051A6FC23C19FA18D321731625FC9', 'CDwindow-532838AFFB2AE8E9EDA90EE64EAF5B35', 'CDwindow-CC54E7485C7B05C3D4B2FB689223BE17', 'CDwindow-28A3CFCF6F2958F3D4467E524BC4FB8E', 'CDwindow-E407D73A0C9F6217C05DE8D4E39BFD4F', 'CDwindow-4AD3703CB6EBB1422CB1372542CF539D', 'CDwindow-CE33E7029F395EA85870BDD5483FFF73', 'CDwindow-0CD0D27B0C3C883A38A741EF599EB349', 'CDwindow-D29CB358CDF127688C3ED6EDCE62348F']`
How I can wait while browser will load his resources after a startup (opened tabs particulary) without time.sleep()
?