Skip to content

Instantly share code, notes, and snippets.

@knorrium
Created April 26, 2012 14:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save knorrium/2500088 to your computer and use it in GitHub Desktop.
Save knorrium/2500088 to your computer and use it in GitHub Desktop.
WebDriver Element focus test
from selenium import webdriver
driver = webdriver.Chrome()
driver.get("http://dev.knorrium.info/wd/focus_test.html")
driver.find_element_by_id("btnFocus").click()
element = driver.find_element_by_id("myAnchor")
focused_element = driver.switch_to_active_element()
#wouldn't a if (element == focused_element) make sense?
if element.__dict__ == focused_element.__dict__:
print "myAnchor element is focused"
else:
print "myAnchor element is not focused"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment