title: Function for alert_is_present() and switch_to_alert()
body: <p>I have code (python / selenium):</p>
  
  <pre><code>    # Alert start
      WebDriverWait(self.driver, 5).until(EC.alert_is_present())
      self.driver.switch_to_alert().dismiss()
      # Alert end
  </code></pre>
  
  <p>The first row wait for alert in the browser and second row press "Cancel" button to dismiss this window. It works fine. I decided to create 2 functions.</p>
  
  <pre><code>    def alertIsPresent(self, timeout=10):
          WebDriverWait(self.driver, timeout).until(EC.alert_is_present())
  
      def alertDismiss(self):
          alert = self.driver.switch_to_alert()
          alert.dismiss()
  </code></pre>
  
  <p>And I call this functions:</p>
  
  <pre><code>    PageObject.alertIsPresent()
      PageObject.alertDismiss()
  </code></pre>
  
  <p>The last ")" is underlined because "parameter self unfilled"...
  I'm newest in python, can you give me suggestion?</p>
  
  <p>pageObjectClass:</p>
  
  <pre><code>class PageObject:
  
  def __init__(self, driver, xpathLocator):
      self.driver = driver
      self.locator = xpathLocator
      self.wait = WebDriverWait(self.driver, 100)
  
  def waitElementToBePresent(self, timeout=10):
      WebDriverWait(self.driver, timeout).until(
          EC.visibility_of_element_located((By.XPATH, self.locator)))
  
  def elementIsPresent(self):
      return EC.visibility_of_element_located((By.XPATH, self.locator))
  
  def alertIsPresent(self, timeout=10):
      WebDriverWait(self.driver, timeout).until(EC.alert_is_present())
  
  def alertDismiss(self):
      alert = self.driver.switch_to_alert()
      alert.dismiss()
  </code></pre>