2 <div id='textDiv'
>Some text we can select
</div>
3 <input id='textfield'
type=
"text" value=
"Text in a textfield">
6 function focus_textfield() {
7 document
.getElementById("textfield").focus();
8 // Focusing the textfiled selects its text. Collapse selection to a cursor.
9 window
.getSelection().collapseToStart();
12 function get_point_inside(element
) {
13 var rect
= element
.getBoundingClientRect();
16 y
: (rect
.top
+ rect
.bottom
) / 2
18 window
.domAutomationController
.send(JSON
.stringify(point
));
21 function get_point_inside_text() {
22 get_point_inside(document
.getElementById('textDiv'));
25 function get_point_inside_textfield() {
26 get_point_inside(document
.getElementById('textfield'));