Menu
WebdriverIODocsAPIHelpVersionsContributeGitHub
WebdriverIO
  • Docs
  • API
  • Help
  • Versions
  • Contribute
  • GitHub
  • Introduction
    • API Docs
  • Protocols
    • Webdriver Protocol
    • Appium
    • JSON Wire Protocol
    • Mobile JSON Wire Protocol
    • Chromium
    • Sauce Labs
    • Selenium Standalone
  • Testrunner
    • Expect
  • browser
    • $$
    • $
    • call
    • custom$$
    • custom$
    • debug
    • deleteCookies
    • execute
    • executeAsync
    • getCookies
    • getWindowSize
    • keys
    • newWindow
    • pause
    • react$$
    • react$
    • reloadSession
    • saveRecordingScreen
    • saveScreenshot
    • setCookies
    • setTimeout
    • setWindowSize
    • switchWindow
    • touchAction
    • uploadFile
    • url
    • waitUntil
  • element
    • $$
    • $
    • addValue
    • clearValue
    • click
    • custom$$
    • custom$
    • doubleClick
    • dragAndDrop
    • getAttribute
    • getCSSProperty
    • getHTML
    • getLocation
    • getProperty
    • getSize
    • getTagName
    • getText
    • getValue
    • isClickable
    • isDisplayed
    • isDisplayedInViewport
    • isEnabled
    • isEqual
    • isExisting
    • isFocused
    • isSelected
    • moveTo
    • react$$
    • react$
    • saveScreenshot
    • scrollIntoView
    • selectByAttribute
    • selectByIndex
    • selectByVisibleText
    • setValue
    • shadow$$
    • shadow$
    • touchAction
    • waitForClickable
    • waitForDisplayed
    • waitForEnabled
    • waitForExist
    • waitUntil

isFocused

Return true or false if the selected DOM-element currently has focus. If the selector matches multiple elements, it will return true if one of the elements has focus.

Usage#
$(selector).isFocused()
Examples#
<input name="login" autofocus="" />
it('should detect the focus of an element', () => {
browser.url('/');
const loginInput = $('[name="login"]');
console.log(loginInput.isFocused()); // outputs: false
loginInput.click();
console.log(loginInput.isFocused()); // outputs: true
})
Edit this page
Previous
« isExisting
Next
isSelected »

Community

  • Twitter
Copyright © 2020 OpenJS Foundation