Focuses on the element, but only if the element
is present, displayed, enabled, and an input. If those conditions are not
met, the focus action will be logged, but skipped and the test will
continue.
359484
public void focus() {
        String cantFocus = "Unable to focus on ";
        String action = "Focusing on " + prettyOutput();
        String expected = prettyOutputStart() + " is present, displayed, and enabled to be focused";
        try {
            if (isNotPresentDisplayedEnabledInput(action, expected, cantFocus)) {
                return;
            }
            WebElement webElement = getWebElement();
            new Actions(driver).moveToElement(webElement).perform();
        } catch (Exception e) {
            log.warn(e);
            reporter.fail(action, expected, cantFocus + prettyOutputEnd() + e.getMessage());
            return;
        }
        reporter.pass(action, expected, "Focused on " + prettyOutputEnd().trim());
    }
212880
def assert_element_visible(self, selector, by=By.CSS_SELECTOR,
                               timeout=settings.SMALL_TIMEOUT):
        
        if self.timeout_multiplier and timeout == settings.SMALL_TIMEOUT:
            timeout = self.__get_new_timeout(timeout)
        self.assert_element(selector, by=by, timeout=timeout)
        return True
641533
function openedChanged(element) {
  if (element.state.autoFocus) {
    if (element.state.opened) {
      // Opened
      if (!element[restoreFocusToElementKey] && document.activeElement !== document.body) {
        // Remember which element had the focus before we were opened.
        element[restoreFocusToElementKey] = document.activeElement;
      }
      // Focus on the element itself (if it's focusable), or the first focusable
      // element inside it.
      // TODO: We'd prefer to require that overlays (like the Overlay base
      // class) make use of delegatesFocus via DelegateFocusMixin, which would
      // let us drop the need for this mixin here to do anything special with
      // focus. However, an initial trial of this revealed an issue in
      // MenuButton, where invoking the menu did not put the focus on the first
      // menu item as expected. Needs more investigation.
      const focusElement = firstFocusableElement(element);
      if (focusElement) {
        focusElement.focus();
      }
    } else {
      // Closed
      if (element[restoreFocusToElementKey]) {
        // Restore focus to the element that had the focus before the overlay was
        // opened.
        element[restoreFocusToElementKey].focus();
        element[restoreFocusToElementKey] = null;
      }
    }
  }
}
1374053
def delayed_assert_element(self, selector, by=By.CSS_SELECTOR,
                               timeout=settings.MINI_TIMEOUT):
        
        self.__delayed_assert_count += 1
        try:
            url = self.get_current_url()
            if url == self.__last_url_of_delayed_assert:
                timeout = 1
            else:
                self.__last_url_of_delayed_assert = url
        except Exception:
            pass
        try:
            self.wait_for_element_visible(selector, by=by, timeout=timeout)
            return True
        except Exception:
            self.__add_delayed_assert_failure()
            return False
510519
function() {

        var activeElement = this.__activeElement;
        var now = getActiveElement();
        var isBlur = arguments[0];
        var node = this.node;

        if (isBlur !== false && node.contains(now)) {
            this.__focus(activeElement);
        }

        this.__autofocus = false;
        removeClass(node, this.__name('focus'));

        return this;
    }
1345515
function assumeButtonFocus(element, button) {
  button.addEventListener('mousedown', event => {
    // Given the main element the focus if it doesn't already have it.
    element.focus();
    // Prevent the default focus-on-mousedown behavior.
    event.preventDefault();
  });
}
493409
function canFocus(elm) {
        if (isTextInputElement(elm) && !elm.hidden) {
          return true;
        }

        if (hasTabstopData(elm)) {
          return true;
        }

        if (/^(button|menuitem|checkbox|tab|menuitemcheckbox|option|gridcell|slider)$/.test(getRole(elm))) {
          return true;
        }

        return false;
      }
79253
function (event) {
            this._hasFocus = true;
            this._setState();
            this._updateDomForState();
            var focusCallback = this._cfg.onfocus;
            if (focusCallback) {
                this.evalCallback(focusCallback);
            }
       }
226957
function (element, scroller) {
                    if (!element || !_Global.document.body || !_Global.document.body.contains(element)) {
                        return false;
                    }
                    if (!_ElementUtilities._setActive(element, scroller)) {
                        return false;
                    }
                    return (element === _Global.document.activeElement);
                }
787597
public void toggleFocus(boolean focusOn) {

        if (focusOn) {
            addStyleName(formCss().focused());
            if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(m_help) || m_hasError) {
                if (shouldDisplayTooltipAbove()) {
                    addStyleName(formCss().displayAbove());
                } else {
                    removeStyleName(formCss().displayAbove());
                }
            } else {
                m_helpBubble.getStyle().setDisplay(Display.NONE);
            }
        } else {
            removeStyleName(formCss().focused());
            if (m_widget != null) {
                if (m_handler.hasSingleOptionalValue()) {
                    if (m_handler.getWidgetService().shouldRemoveLastValueAfterUnfocus(m_widget)) {
                        m_handler.removeAttributeValue(this);
                    }

                }
            }
        }
    }
722968
function(select){
        var focusElement = this.tmpl ? this.tmpl.focus || this.element : null;

        if (focusElement)
        {
          if (focusTimer)
            focusTimer = basis.clearImmediate(focusTimer);

          focusTimer = basis.setImmediate(function(){
            try {
              focusElement.focus();
              if (select)
                focusElement.select();
            } catch(e) {}
          });
        }
      }
1002204
function(setFocus) {
		var node = this.activeNode;
		if( node ) {
			this.activeNode = null; // Force re-activating
			node.setActive();
			if( setFocus ){
				node.setFocus();
			}
		}
	}
234645
function(e) {
			var self = this;
			var wasFocused = self.isFocused;
	
			if (self.isDisabled) {
				self.blur();
				e && e.preventDefault();
				return false;
			}
	
			if (self.ignoreFocus) return;
			self.isFocused = true;
			if (self.settings.preload === 'focus') self.onSearchChange('');
	
			if (!wasFocused) self.trigger('focus');
	
			if (!self.$activeItems.length) {
				self.showInput();
				self.setActiveItem(null);
				self.refreshOptions(!!self.settings.openOnFocus);
			}
	
			self.refreshState();
		}
43635
@Override
	public void focus() {
		if (cp.getDebugMode() == true
				&& (cp.getBrowser().equalsIgnoreCase("ie")
						|| cp.getBrowser().equalsIgnoreCase("*iexplore") || cp
						.getBrowser().equalsIgnoreCase("iexplore")))

			windowFocus();
		else if (doFocusOnClick)
			windowFocus();
	}
633956
@Then("^the element on index '(\\d+?)' (IS|IS NOT) selected$")
    public void assertSeleniumIsSelected(Integer index, Boolean isSelected) {
        assertThat(this.commonspec, commonspec.getPreviousWebElements()).as("There are less found elements than required")
                .hasAtLeast(index);
        assertThat(this.commonspec, commonspec.getPreviousWebElements().getPreviousWebElements().get(index).isSelected()).as(
                "Unexpected element selected property").isEqualTo(isSelected);
    }
366572
function doFocusExit(el, fromElement, toElement) {
    el.dispatchEvent(new CustomEvent('focusExit', {
        detail: { fromElement: fromElement, toElement: toElement },
        bubbles: false // mirror the native mouseleave event
    }));
}
679924
function() {
            // If lockup is already locked don't try to disable inputs again
            if (this.$pinny.lockup('isLocked')) {
                return;
            }

            var $focusableElements = $(FOCUSABLE_ELEMENTS).not(function() {
                return $(this).isChildOf('.' + classes.PINNY);
            });

            $focusableElements.each(function(_, el) {
                var $el = $(el);
                var currentTabIndex = $el.attr('tabindex') || 0;

                $el
                    .attr('data-orig-tabindex', currentTabIndex)
                    .attr('tabindex', '-1');
            });
        }