Created
August 5, 2016 19:44
-
-
Save brizandrew/0059df27ce9ca3ac5287d913c64cf801 to your computer and use it in GitHub Desktop.
This file contains 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 import webdriver | |
from selenium.common.exceptions import NoSuchElementException | |
""" | |
@function elementExists | |
Checks if a given element exists on the driver page given a search type and value | |
@param {WebDriver} driver: The driver to search for | |
@param {str} locateType: The type of search to preform (only "by_id" is supported) | |
@param {str} locateValue: The value of a given type to search for (only "id" is supported) | |
@return {boolean}: Whether or not it exists | |
""" | |
def elementExists(driver, locateType, locateValue): | |
try: | |
if locateType == 'id': | |
driver.find_element_by_id(locateValue) | |
return True | |
except NoSuchElementException: | |
return False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment