How do I test which element has the focus in Selenium RC?
问题 How do I test which element has the focus in Selenium RC? 回答1: I couldn't get the :focus pseudoclass idea to work, not sure why - targeting css=#search_input input.text matched, but css=#search_input input.text:focus didn't? But here is what worked for me: self.assertEquals(self.se.get_element_index('dom=document.activeElement'), self.se.get_element_index('//input[@id="search-query"]')) This is using the Python Selenium API, so the get_element_index() calls are wrappers around the core