Created
June 5, 2013 17:32
-
-
Save shofetim/5715683 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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