# Buggy code
def _follow_selected_cb(self, js_elem, tab=False):
    """Callback for javascript which clicks the selected element.

    Args:
        js_elem: The element serialized from javascript.
        tab: Open in a new tab.
    """
    if js_elem is None:
        return
    if js_elem == "focused":
        # we had a focused element, not a selected one. Just send <enter>
        self._follow_enter(tab)
        return

    assert isinstance(js_elem, dict), js_elem
    elem = webengineelem.WebEngineElement(js_elem, tab=self._tab)
    if tab:
        click_type = usertypes.ClickTarget.tab
    else:
        click_type = usertypes.ClickTarget.normal

    # Only click if we see a link
    if elem.is_link():
        log.webview.debug(
            "Found link in selection, clicking. ClickTarget {}, elem {}".format(
                click_type, elem
            )
        )
        elem.click(click_type)


# Traceback (qutebrowser.browser.webelem.Error)
08:20:52 DEBUG    commands   command:run:491 command called: follow-selected
08:20:52 DEBUG    commands   command:run:506 Calling qutebrowser.browser.commands.CommandDispatcher.follow_selected(<qutebrowser.browser.commands.CommandDispatcher>, tab=False)
08:20:52 DEBUG    modes      modeman:_handle_keypress:199 match: 2, forward_unbound_keys: auto, passthrough: False, is_non_alnum: True, dry_run: False --> filter: True (focused: <PyQt5.QtWidgets.QWidget object at 0x7fd2640f1d38>)
08:20:52 DEBUG    webview    webenginetab:_follow_selected_cb:362 Found link in selection, clicking. ClickTarget ClickTarget.normal, elem adblock-update
08:20:52 DEBUG    webelem    webelem:click:405 Clicking <qutebrowser.browser.webengine.webengineelem.WebEngineElement html='<a href="#adblock-update">adblock-update</a>'> with click_target ClickTarget.normal, force_event False
08:20:52 DEBUG    webelem    webelem:is_editable:249 Checking if element is editable: <qutebrowser.browser.webengine.webengineelem.WebEngineElement html='<a href="#adblock-update">adblock-update</a>'>
08:20:52 ERROR    misc       crashsignal:exception_hook:214 Uncaught exception
Traceback (most recent call last):
File "/home/florian/proj/qutebrowser/git/qutebrowser/browser/webengine/webenginetab.py", line 380, in <lambda>
self._follow_selected_cb(jsret, tab))
File "/home/florian/proj/qutebrowser/git/qutebrowser/browser/webengine/webenginetab.py", line 363, in _follow_selected_cb
elem.click(click_type)
File "/home/florian/proj/qutebrowser/git/qutebrowser/browser/webelem.py", line 422, in click
self._click_fake_event(click_target)
File "/home/florian/proj/qutebrowser/git/qutebrowser/browser/webelem.py", line 336, in _click_fake_event
pos = self._mouse_pos()
File "/home/florian/proj/qutebrowser/git/qutebrowser/browser/webelem.py", line 327, in _mouse_pos
raise Error("Element position is out of view!")
qutebrowser.browser.webelem.Error: Element position is out of view!

# Fixed code
def _follow_selected_cb(self, js_elem, tab=False):
    """Callback for javascript which clicks the selected element.

    Args:
        js_elem: The element serialized from javascript.
        tab: Open in a new tab.
    """
    if js_elem is None:
        return
    if js_elem == "focused":
        # we had a focused element, not a selected one. Just send <enter>
        self._follow_enter(tab)
        return

    assert isinstance(js_elem, dict), js_elem
    elem = webengineelem.WebEngineElement(js_elem, tab=self._tab)
    if tab:
        click_type = usertypes.ClickTarget.tab
    else:
        click_type = usertypes.ClickTarget.normal

    # Only click if we see a link
    if elem.is_link():
        log.webview.debug(
            "Found link in selection, clicking. ClickTarget {}, elem {}".format(
                click_type, elem
            )
        )
        try:
            elem.click(click_type)
        except webelem.Error as e:
            message.error(str(e))
            return