Skip to content

Commit bb8d01b

Browse files
browser: update finders-filters doc examples. add link to external css selectors site (#736)
1 parent 3a40d02 commit bb8d01b

4 files changed

Lines changed: 38 additions & 9 deletions

File tree

webtau-docs/znai/UI/finders-and-filters.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,33 @@ type: two-sides
66

77
Finders in webtau is the initial web element selection that could select one or more elements.
88

9-
# By CSS
9+
# CSS Finder
1010

11-
Use `$` to select an element by a given `css` selector.
11+
Use `$` to select an element by a given `css` selector ([Read W3Schools CSS selectors](https://www.w3schools.com/cssref/css_selectors.asp) to learn all kind of CSS selection techniques).
1212

13-
:include-file: doc-artifacts/snippets/finders-filters/byCss.groovy
13+
:include-file: doc-artifacts/snippets/finders-filters/byCss.groovy {title: "example of selecting by id"}
1414

1515
If more than one element is matched, the first one will be used for actions and assertions.
1616

17-
:include-file: doc-artifacts/snippets/finders-filters/byCssFirstMatched.groovy
17+
:include-file: doc-artifacts/snippets/finders-filters/byCssFirstMatched.groovy {title: "example of selecting by nested tags"}
1818

1919
While `click` and `sendKeys` will always work on a first element only, the matchers can work with a list of things.
2020

2121
:include-file: doc-artifacts/snippets/finders-filters/byCssAllMatched.groovy
2222

2323
Note: declaring element this way will not trigger element search right away.
2424

25-
:include-xml: doc-artifacts/snippets/finders-filters/flat-menu.html {rightSide: true, paths: ["div.div[0]", "div.div[1].ul.li[0].a"]}
25+
:include-meta: {rightSide: true}
26+
27+
:include-empty-block:
28+
29+
:include-xml: doc-artifacts/snippets/finders-filters/welcome.html
30+
31+
:include-xml: doc-artifacts/snippets/finders-filters/flat-menu.html {paths: ["div.div[0]", "div.div[1].ul.li[0].a"]}
2632

2733
# Filters
2834

29-
You can use filters to narrow down elements selected by finders like `css`.
35+
You can use filters to narrow down elements selected by finders.
3036

3137
Filter comes in a way of `get` method. Parameter is one of the following
3238
* Element number

webtau-docs/znai/UI/page-element-and-value.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,26 @@
1+
# Element Selection
2+
3+
Use `$('css-selector')` to select a page element.
4+
5+
```groovy {title: "select by id"}
6+
$('#element-id')
7+
```
8+
9+
```groovy {title: "select by class"}
10+
$('.label')
11+
```
12+
13+
```groovy {title: "select by attribute"}
14+
$('[data-test-id="my-id"]')
15+
```
16+
17+
[Read Finders And Filters](UI/finders-and-filters) to learn how to select elements using more advanced techniques.
18+
19+
[Read W3Schools CSS selectors](https://www.w3schools.com/cssref/css_selectors.asp) to learn all kind of CSS selection techniques.
20+
121
# Lazy Element
222

3-
When you use `$('.css')` you create instance of `PageElement`.
23+
When you use `$('css-selector')` you create an instance of `PageElement`.
424

525
`PageElement` represent an element that is present or *will be present* on a web page. It is safe to declare an element
626
before you open a browser or navigate to the page you need to test.

webtau-feature-testing/src/test/groovy/org/testingisdocumenting/webtau/featuretesting/WebTauBrowserFeaturesTestBase.groovy

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,8 @@ class WebTauBrowserFeaturesTestBase {
140140
])
141141

142142
extractHtmlSnippets(root, 'finders-and-filters.html', [
143-
'flat-menu.html': '#menu'
143+
'welcome.html': '#welcome-wrapper',
144+
'flat-menu.html': '#menu'
144145
])
145146
}
146147

webtau-feature-testing/src/test/resources/finders-and-filters.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818
<body>
1919
<div id="simple-case">
2020
<div>
21-
<div id="welcome">hello</div>
21+
<div id="welcome-wrapper">
22+
<div id="welcome">hello</div>
23+
</div>
2224
<div id="menu">
2325
<ul>
2426
<li>

0 commit comments

Comments
 (0)