Codeception: Check if element has focus?
问题 Is there a way to assert that an element (e.g. input or link) has the keyboard focus? I'm using Codeception with Selenium. Couldn't find anything on http://codeception.com/docs/modules/WebDriver 回答1: A reliable source told me this works: $I->executeJS('return $("#element").is(":focus")'); Happy testing! 回答2: Some more details to the answer by @sunomad Activate Codeception's Asserts Module in your acceptance.suite.yml : modules: enabled: # ... - Asserts Then use this in an Acceptance test: