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