parent
7a98af4c2f
commit
ea4f4e197f
@ -39,7 +39,8 @@ import pygments.formatters
|
||||
|
||||
from qutebrowser.commands import userscripts, cmdexc, cmdutils, runners
|
||||
from qutebrowser.config import config, configexc
|
||||
from qutebrowser.browser import urlmarks, browsertab, inspector, navigate
|
||||
from qutebrowser.browser import (urlmarks, browsertab, inspector, navigate,
|
||||
webelem)
|
||||
from qutebrowser.browser.webkit import webkitelem, downloads, mhtml
|
||||
from qutebrowser.keyinput import modeman
|
||||
from qutebrowser.utils import (message, usertypes, log, qtutils, urlutils,
|
||||
@ -1559,7 +1560,11 @@ class CommandDispatcher:
|
||||
if elem is None:
|
||||
message.error(self._win_id, "No element found!")
|
||||
return
|
||||
elem.click(target)
|
||||
try:
|
||||
elem.click(target)
|
||||
except webelem.Error as e:
|
||||
message.error(self._win_id, str(e))
|
||||
return
|
||||
|
||||
# def multiple_cb(elems):
|
||||
# """Click multiple elements (with only one expected)."""
|
||||
|
@ -211,13 +211,16 @@ class HintActions:
|
||||
window=self._win_id)
|
||||
tabbed_browser.set_mark("'")
|
||||
|
||||
if context.target == Target.hover:
|
||||
elem.hover()
|
||||
elif context.target == Target.current:
|
||||
elem.remove_blank_target()
|
||||
elem.click(target_mapping[context.target])
|
||||
else:
|
||||
elem.click(target_mapping[context.target])
|
||||
try:
|
||||
if context.target == Target.hover:
|
||||
elem.hover()
|
||||
elif context.target == Target.current:
|
||||
elem.remove_blank_target()
|
||||
elem.click(target_mapping[context.target])
|
||||
else:
|
||||
elem.click(target_mapping[context.target])
|
||||
except webelem.Error as e:
|
||||
raise HintingError(str(e))
|
||||
|
||||
def yank(self, url, context):
|
||||
"""Yank an element to the clipboard or primary selection.
|
||||
|
@ -353,7 +353,10 @@ class AbstractWebElement(collections.abc.MutableMapping):
|
||||
rect.setWidth(rect.height())
|
||||
else:
|
||||
rect.setHeight(rect.width())
|
||||
return rect.center()
|
||||
pos = rect.center()
|
||||
if pos.x() < 0 or pos.y() < 0:
|
||||
raise Error("Element position is out of view!")
|
||||
return pos
|
||||
|
||||
def click(self, click_target):
|
||||
"""Simulate a click on the element."""
|
||||
|
@ -5,6 +5,7 @@
|
||||
<title>Scrolling</title>
|
||||
</head>
|
||||
<body>
|
||||
<a href="/data/hello.txt" id="link">Just a link</a>
|
||||
<pre>
|
||||
0
|
||||
1
|
||||
|
@ -9,6 +9,14 @@ Feature: Using hints
|
||||
And I hint with args "links normal" and follow xyz
|
||||
Then the error "No hint xyz!" should be shown
|
||||
|
||||
Scenario: Following a link after scrolling down
|
||||
When I open data/scroll/simple.html
|
||||
And I run :hint links normal
|
||||
And I wait for "hints: *" in the log
|
||||
And I run :scroll-page 0 1
|
||||
And I run :follow-hint a
|
||||
Then the error "Element position is out of view!" should be shown
|
||||
|
||||
### Opening in current or new tab
|
||||
|
||||
@qtwebengine_todo: createWindow is not implemented yet
|
||||
|
@ -619,3 +619,9 @@ Feature: Various utility commands.
|
||||
And the following tabs should be open:
|
||||
- data/click_element.html
|
||||
- data/hello.txt (active)
|
||||
|
||||
Scenario: Clicking an element which is out of view
|
||||
When I open data/scroll/simple.html
|
||||
And I run :scroll-page 0 1
|
||||
And I run :click-element id link
|
||||
Then the error "Element position is out of view!" should be shown
|
||||
|
Loading…
Reference in New Issue
Block a user