- From: <bugzilla@jessica.w3.org>
- Date: Tue, 27 Oct 2015 17:05:46 +0000
- To: public-browser-tools-testing@w3.org
https://www.w3.org/Bugs/Public/show_bug.cgi?id=29247 Bug ID: 29247 Summary: [WebDriver Spec]: Add support for interacting with text nodes Product: Browser Test/Tools WG Version: unspecified Hardware: All OS: All Status: NEW Severity: normal Priority: P2 Component: WebDriver Assignee: public-browser-tools-testing@w3.org Reporter: mfulton26@gmail.com QA Contact: public-browser-tools-testing@w3.org CC: mike@w3.org Blocks: 20860 Target Milestone: --- In addition to `WebElement` can a `WebText` be added? A `WebText` would be to [text](https://developer.mozilla.org/en-US/docs/Web/API/Text) nodes what `WebElement` is to [element](https://developer.mozilla.org/en-US/docs/Web/API/Element) nodes. Sometimes it is enough to use the element containing text but this can be problematic when an element containing text also contains elements. e.g. Without using `JavascriptExecutor` it is not possible, at least to my knowledge, to click the text `"First name: "` in `<label>First name: <input type="text" name="fname"></label>` (which, in this example, should cause the input element to get focus). A `WebText` interface might be as follows: ```java public interface WebText extends TakesScreenshot { void click(); void sendKeys(CharSequence... keysToSend); void clear(); boolean isSelected(); String getText(); boolean isDisplayed(); Point getLocation(); Dimension getSize(); String getCssValue(String propertyName); } ``` Other potential `WebText` methods might include `select()` (to highlight/select the text) and `select(String)` (to highlight/select a substring of the text). Additional methods to `SearchContext` such as `findTexts(By)` and `findText(By)` would also make sense. I believe that `WebElement`'s `submit()`, `getTagName()`, `getAttribute(String)`, `isEnabled()`, `findElements(By)`, and `findElement(By)` methods would not make sense to include. A new `WebNode` interface might even be worthwhile for both `WebElement` and `WebText` to extend to declare the common methods between them. Notes: 1. The `sendKeys(CharSequence...)` and `clear()` methods on a `WebText` would be especially useful when dealing with text nodes in [Content Editable](https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Content_Editable) elements. e.g. Double-click or otherwise select the text to highlight it and then send keys to overwrite it, etc. 2. `WebText.isSelected()` would return true if the user has highlighted/selected the text; otherwise false. 3. In addition to being able to "find" elements and text on the page and interact with them, the capability to send a text node over the JSON wire protocol in addition to element nodes would allow automation scripts using `JavascriptExecutor` to "list" or "query" for relevant text and element nodes on the page. e.g. Such a script might list all displayed nodes. On a simple login page it would return a list such as `[WebText[Email: ], WebElement[<input type="email">], WebText[Password: ], WebElement[<input type="password">], WebElement[<input type="submit" value="Login">]]`. This would allow the automation script to list text nodes, input elements, select elements, button elements, etc. and then interact with them inferring what they are based on their tagName, attributes, and relative positioning in the list (e.g. the password input should be the element immediately following the text "Password: "). This would seem to get closer to automating how a user interacts with a page instead of searching within a page's DOM for elements by id, name, xpath, css selector, etc. Referenced Bugs: https://www.w3.org/Bugs/Public/show_bug.cgi?id=20860 [Bug 20860] WebDriver Level 1 -- You are receiving this mail because: You are the QA Contact for the bug.
Received on Tuesday, 27 October 2015 17:05:49 UTC