Skip to content

Instantly share code, notes, and snippets.

@eirenik0
Created January 3, 2020 11:29
Show Gist options
  • Save eirenik0/4183a11a901f488d1bdbb4d7b1f7a859 to your computer and use it in GitHub Desktop.
Save eirenik0/4183a11a901f488d1bdbb4d7b1f7a859 to your computer and use it in GitHub Desktop.
def css_selector_from_(by, value):
if by == By.ID:
value = "#%s" % value
elif by == By.CLASS_NAME:
value = ".%s" % value
elif by == By.NAME:
value = '[name="%s"]' % value
elif by in [By.XPATH, By.CSS_SELECTOR, By.TAG_NAME]:
value = value
else:
raise TypeError("By {} is not supported".format(by))
return value
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment