title: Sending an elem.click() if button pressed in a while loop combined with a for loop
body: <pre><code>import pyautogui as py
  from selenium import webdriver
  from selenium.webdriver.common.keys import Keys
  import keyboard
  driver = webdriver.Chrome()
  driver.get('https://www.youtube.com/watch?v=pcel9QTPx_g&amp;list=RDpcel9QTPx_g&amp;start_radio=1&amp;t=11&amp;ab_channel=%E5%BE%AE%E7%B3%96%E9%80%A2')
  elem = driver.find_elements_by_id('video-title')
  while True:
      if keyboard.is_pressed('`'):
          driver.find_element_by_xpath('//*[@id=&quot;movie_player&quot;]/div[29]/div[2]/div[1]/button'.click()
      for x in elem:
          elem.click()
          keyboard.wait('f4)
  </code></pre>
  <p>So i am trying to automate iterating through a bunch of songs playlist in selenium using python. I am trying make the code so when i pressed `, the video will pause and if i pressed f4 the code will skips to the next iteration. The f4 function is working just fine but the code inside the while loop isn't. Is it because when the code runs, when it gets to the for loop it won't get access to the while loop anymore? If you guys have any ideas or want to simplify my code feel free to answer!</p>