title: selenim web driver python repet code ultimate
body: <p>how repeat code again again again this every work 
  I want the code below to always work and it should be repeated, and again this function should be repeated and not removed from the program.</p>
  
  <pre><code>def ref(self):
      driver = self.driver
      nextB2 = driver.find_element_by_xpath("""//section/span/button/span[@aria-label='Like']""")
      nextB2.click()
      time.sleep(5)
      nextB3 = driver.find_element_by_xpath("""//section/span/button/span[@aria-label='Like']""")
      nextB3.click()
      time.sleep(6)
      nextB4 = driver.find_element_by_xpath("""//section/span/button/span[@aria-label='Like']""")
      nextB4.click()
      time.sleep(7)
      driver.refresh()
      time.sleep(5)
      driver.switch_to_frame('ref')
      driver.refresh('ref')
  </code></pre>