Skip to content

Instantly share code, notes, and snippets.

@shofetim
Created June 5, 2013 17:32
Show Gist options
  • Select an option

  • Save shofetim/5715683 to your computer and use it in GitHub Desktop.

Select an option

Save shofetim/5715683 to your computer and use it in GitHub Desktop.
from selenium.common.exceptions import NoSuchElementException, ElementNotSelectableException
from selenium.webdriver.common.by import By
def clickit(driver, bytype, loc):
#
# required parms
#
# driver - web page to click on ( driver instance from webdriver )
# bytype - ID, XPATH, CSS, Etc...
# loc - location of where to find the item(s) to click on
# BLANK is allowed with the -c or -a option
try:
ele = driver.find_element(bytype, loc)
ele.click()
except NoSuchElementException:
print("qaclickit - Unable to find element By.Type= " + str (bytype) + " locator= " + loc)
return False
except ElementNotSelectableException:
print("qaclickit - Unable to click By.Type= " + str (bytype) + " locator= " + loc)
return False
return True # all's well
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment