title: Selenium - Refresh all tabs after X time
body: <p>I have a rotating dash created via selenium webdriver and I am noticing the pages will need to be refreshed every few hours. How can I add this to the code?</p>
  
  <p>There are 8 tabs open and it cycles through each tab every 10 seconds. Looking for a way to refresh all open tabs every 2-3 hours. Current code. </p>
  
  <pre><code>from selenium import webdriver
  from selenium.webdriver.chrome.options import Options
  from selenium.webdriver.common.by import By
  from selenium.webdriver.support.ui import WebDriverWait
  from selenium.webdriver.support import expected_conditions as EC
  import time
  usernameStr = 'USERNAME'
  passwordStr = 'PASSWORD'
  
  options = Options()
  options.add_argument('--maximized')
  options.add_argument('disable-infobars')
  driver = webdriver.Chrome(chrome_options=options, executable_path=r'C:\Users\pc\Desktop\chromedriver.exe')
  driver.get('https://Sign in link')
  # fill in username and hit the next button
  username = driver.find_element_by_id('username')
  username.send_keys(usernameStr)
  password = WebDriverWait(driver, 10).until(
      EC.presence_of_element_located((By.ID, 'password')))
  password.send_keys(passwordStr)
  nextButton = driver.find_element_by_class_name('emp-submit')
  nextButton.click()
  
  #second tab
  driver.execute_script("window.open('about:blank', 'tab2');")
  driver.switch_to.window("tab2")
  driver.get('https://link#2')
  
  #third tab
  driver.execute_script("window.open('about:blank', 'tab3');")
  driver.switch_to.window("tab3")
  driver.get('https://link#3')
  
  #fourth tab
  driver.execute_script("window.open('about:blank', 'tab4');")
  driver.switch_to.window("tab4")
  driver.get('https://link#4')
  
  #fifth tab
  driver.execute_script("window.open('about:blank', 'tab5');")
  driver.switch_to.window("tab5")
  driver.get('https://link#5')
  
  #sixth tab
  driver.execute_script("window.open('about:blank', 'tab6');")
  driver.switch_to.window("tab6")
  driver.get('https://link#6')
  
  #seventh tab
  driver.execute_script("window.open('about:blank', 'tab7');")
  driver.switch_to.window("tab7")
  driver.get('https://link#7')
  
  #eigth tab
  driver.execute_script("window.open('about:blank', 'tab8');")
  driver.switch_to.window("tab8")
  driver.get('https://link#8')
  
  while True:
      Windows = driver.window_handles
      for window in Windows:
          driver.switch_to.window(window)
          time.sleep(10)
  </code></pre>