<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>29135</bug_id>
          
          <creation_ts>2015-09-18 10:33:04 +0000</creation_ts>
          <short_desc>[WebDriver Spec]: Missing text/selection manipulation primitives</short_desc>
          <delta_ts>2015-10-31 03:27:13 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>Browser Test/Tools WG</product>
          <component>WebDriver</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          <blocked>24121</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter>w3c.org</reporter>
          <assigned_to name="Browser Testing and Tools WG">public-browser-tools-testing</assigned_to>
          <cc>ato</cc>
    
    <cc>dburns</cc>
    
    <cc>mike</cc>
          
          <qa_contact name="Browser Testing and Tools WG">public-browser-tools-testing</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>123254</commentid>
    <comment_count>0</comment_count>
    <who name="">w3c.org</who>
    <bug_when>2015-09-18 10:33:04 +0000</bug_when>
    <thetext>As far as I could see, the WebDriver spec currently provides very little in terms of emulating textual manipulations.

NOTE: I will use the term &quot;insertion point&quot; to refer to the textual cursor within e.g. a text box, to differentiate it from the &quot;pointer&quot; cursor

# Current Provisions

* the entire textual content of an element can be retrieved
* it is possible to [clear] an element or [sendKeys] to it (emulating keyboard input)
* implicitly, the insertion point and selection can be manipulated using actions (click and pointerDown/pointerMove/pointerUp).

# Primary Issues

Pointer actions work in term of offsets, but as far as I could tell

* the specification provides no way to perform textual matching and transform that into bounding boxes, thus no way to easily position the insertion point or draw selections
* the specification provides no way to query the insertion point or selection for position or bounding boxe, thus no way to get simple feedback while probing blindly

# Use case

Test/demonstrate RTEs or other contenteditable elements, allow cross-platform text insertion within existing textual nodes rather than just around them

# Possible solutions?

Rect textRect(needle[, element][, skip])

* would return the same thing as Element Rect ({x, y, width, height} relative to the document element).
  - would only match visible text (so text contained in a visible element)
  - would generate an error if no matching visible text is found?
* needle would be the text to look for, possibly a regex? The specification does not currently use regex anywhere so that might be a bit much.
* skip would probably be necessary as the reference text could occur multiple times in the source.
* a WebElement &quot;root reference&quot; would probably allow easier precise matching and less skipping.

* Testing Chrome, Firefox and Safari on OSX, selecting a glyph requires going through the majority of the glyph so selecting from a textual boundary won&apos;t risk selecting the preceding glyph.
* It&apos;s somewhat inconvenient for single-letter boundary selections though as there might be need for lots of skipping.
* It doesn&apos;t try to count characters/glyphs and thus might help avoid possible confusion issues with respect to code units, normalisation (maybe?), codepoints and glyphs at the interface-level (these concerns may have to be handled at the spec level though).

## Unknowns for this possible solution

* would/should it be possible to match text across multiple elements? This is possible for users e.g. my browser&apos;s in-page search will find a match for &quot;requests | preferences&quot; on the current page even tough that spans two links and a span in two separate list elements.
* would/should the rect be augmented with the text&apos;s container element(s) in the style of a DOM Range? It doesn&apos;t seem to make much sense from a user-interaction perspective.

# Unsolved

Should it be possible to query the current selection&apos;s span/rect as well, independently from arbitrary text? I don&apos;t have a use-case for that right now but a &quot;living&quot; user would see the current text selection displayed in the UI so it could make sense.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>124021</commentid>
    <comment_count>1</comment_count>
    <who name="Andreas Tolfsen">ato</who>
    <bug_when>2015-10-31 03:27:13 +0000</bug_when>
    <thetext>This seems somewhat related to bug 29247.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>