If the window closes too quickly, switch_to_window is invalid #1435
              
                
                  
                  
                    Answered
                  
                  by
                    mdmintz
                  
              
          
                  
                    
                      chenqinggang001
                    
                  
                
                  asked this question in
                Q&A
              
            -
| If the window closes too quickly, switch_to_window is invalid I can't predict how long I will have to wait for my next step, so can there be a waiting period like   | 
Beta Was this translation helpful? Give feedback.
      
      
          Answered by
          
            mdmintz
          
      
      
        Jul 27, 2022 
      
    
    Replies: 1 comment 3 replies
-
| You might be able to close the active window/tab directly, and then switch to the most recent one after that: self.driver.close()
self.switch_to_window(-1) | 
Beta Was this translation helpful? Give feedback.
                  
                    3 replies
                  
                
            
      Answer selected by
        mdmintz
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
You might be able to close the active window/tab directly, and then switch to the most recent one after that: