Skip to content

Commit febe886

Browse files
pekkaklarckaaltat
authored andcommitted
Browser management doc and message update (#952)
* Clean up window tests. Also add explicit tests for using "Set Window Position/Size" with strings. Selenium seems to already convert values passed to it to integers, decided to add conversion also to these keywords so that we don't depent on that behavior. - Move default locator strategy docs to beginning of the whole locator strategy section. This is the most common approach. - Move note about old limitation with tables to a new place. Documentation cleanup is related to #925. Select Frame and Select Window documentation still todo.
1 parent 1ba9326 commit febe886

5 files changed

Lines changed: 300 additions & 294 deletions

File tree

‎src/SeleniumLibrary/__init__.py‎

Lines changed: 31 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,32 @@ class SeleniumLibrary(DynamicCore):
7676
can either be explicitly specified with a prefix or the strategy can be
7777
implicit.
7878
79+
=== Default locator strategy ===
80+
81+
By default locators are considered to use the keyword specific default
82+
locator strategy. All keywords support finding elements based on ``id``
83+
and ``name`` attributes, but some keywords support additional _key
84+
attributes_ that make sense in their context. For example, `Click Link`
85+
supports the link text and the ``href`` attribute in addition to the
86+
normal ``id`` and ``name``.
87+
88+
Examples:
89+
90+
| `Click Element` | example | # Match based on ``id`` or ``name``. |
91+
| `Click Link` | example | # Match also based on link text and ``href``. |
92+
| `Click Button` | example | # Match based on ``id``, ``name`` or ``value``. |
93+
94+
If a locator accidentally starts with a prefix recognized as `explicit
95+
locator strategy` or `implicit XPath strategy`, it is possible to use
96+
the explicit ``default`` prefix to enable the default strategy.
97+
98+
Examples:
99+
100+
| `Click Element` | name:foo | # Find element with name ``foo``. |
101+
| `Click Element` | default:name:foo | # Use default strategy with value ``name:foo``. |
102+
| `Click Element` | //foo | # Find element using XPath ``//foo``. |
103+
| `Click Element` | default://foo | # Use default strategy with value ``//foo``. |
104+
79105
=== Explicit locator strategy ===
80106
81107
The explicit locator strategy is specified with a prefix using either
@@ -109,8 +135,8 @@ class SeleniumLibrary(DynamicCore):
109135
prefix is only necessary if the locator value itself accidentally
110136
matches some of the explicit strategies.
111137
112-
Spaces around the separator are ignored, so ``id : foo``, ``id: foo``
113-
and ``id:foo`` are all equivalent.
138+
Spaces around the separator are ignored, so ``id:foo``, ``id: foo``
139+
and ``id : foo`` are all equivalent.
114140
115141
Examples:
116142
@@ -121,6 +147,9 @@ class SeleniumLibrary(DynamicCore):
121147
Notice that using the ``sizzle`` strategy or its alias ``jquery``
122148
requires that the system under test contains the jQuery library.
123149
150+
Notice also that prior to SeleniumLibrary 3.0, table related keywords
151+
only supported ``xpath``, ``css`` and ``sizzle/jquery`` strategies.
152+
124153
=== Implicit XPath strategy ===
125154
126155
If the locator starts with ``//`` or ``(//``, the locator is considered
@@ -134,32 +163,6 @@ class SeleniumLibrary(DynamicCore):
134163
135164
The support for the ``(//`` prefix is new in SeleniumLibrary 3.0.
136165
137-
=== Default locator strategy ===
138-
139-
By default locators are considered to use the keyword specific default
140-
locator strategy. All keywords support finding elements based on ``id``
141-
and ``name`` attributes, but some keywords support additional _key
142-
attributes_ that make sense in their context. For example, `Click Link`
143-
supports the link text and the ``href`` attribute in addition to the
144-
normal ``id`` and ``name``.
145-
146-
Examples:
147-
148-
| `Click Element` | example | # Match based on ``id`` or ``name``. |
149-
| `Click Link` | example | # Match also based on link text and ``href``. |
150-
| `Click Button` | example | # Match based on ``id``, ``name`` or ``value``. |
151-
152-
If the locator accidentally starts with some of the explicit locator
153-
prefixes or with the implicit XPath prefixes, it is possible to use
154-
the explicit ``default`` prefix to enable the default strategy.
155-
156-
Examples:
157-
158-
| `Click Element` | name:foo | # Find element with name ``foo``. |
159-
| `Click Element` | default:name:foo | # Use default strategy with value ``name:foo``. |
160-
| `Click Element` | //foo | # Find element using XPath ``//foo``. |
161-
| `Click Element` | default://foo | # Use default strategy with value ``//foo``. |
162-
163166
== Using WebElements ==
164167
165168
In addition to specifying a locator as a string, it is possible to use
@@ -196,13 +199,6 @@ class SeleniumLibrary(DynamicCore):
196199
197200
See the `Add Location Strategy` keyword for more details.
198201
199-
== Locating tables ==
200-
201-
Starting from release 3.0.0, it is possible to locate table using all
202-
strategies supported by the library. Prior the release 3.0 tables
203-
could have been located with limited set of strategies and with
204-
limitations in the strategy.
205-
206202
= Timeouts, waits and delays =
207203
208204
This section discusses different ways how to wait for elements to

0 commit comments

Comments
 (0)