title: How to switch to a modal in Python using Selenium
body: <p>I'm using Python and Selenium. My problem is that I can't switch on the modal that pops out and I can't click the buttons in it.</p>
  <p>This is the elements of the modal:</p>
  <p><a href="https://i.stack.imgur.com/8I5yd.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8I5yd.jpg" alt="" /></a></p>
  <p>This is my code:</p>
  <h1>minus the url of course</h1>
  <pre><code>browser = webdriver.Chrome(executable_path=&quot;D:\\sasdsa\\automate\\chromedriver_win32\\chromedriver.exe&quot;)
  user_name = browser.find_element_by_xpath(&quot;//input[@id='username']&quot;)
  user_name.send_keys(&quot;test.employee&quot;)
  
  ##Password
  pass_word = browser.find_element_by_xpath(&quot;//input[@id='password']&quot;)
  pass_word.send_keys(&quot;123&quot;)
  
  ##log_in = browser.find_element_by_css_selector(&quot;.btn&quot;)
  log_in = browser.find_element_by_xpath(&quot;//button[@class='btn btn-sm btn-primary btn-block']&quot;)
  log_in.click()
  
  ##punch
  #driver.find_element_by_id(&quot;//@id='product_view')
  #To open the modal
  punch_in = browser.find_element_by_xpath(&quot;//button[@class='btn btn-success btn-sm pull-right']&quot;)
  punch_in.click()
  
  
  #cant switch to the modal to access the button
  browser.switch_to_frame(&quot;product_view&quot;)
  punch_in2 = browser.find_element_by_xpath(&quot;//button[@id='save_me']&quot;)
  punch_in2.click()
  </code></pre>