-
-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add docs/selene-quick-start-tutorial.md with images * add docs/selene-in-action-tutorial.md with images * add docs/selene-for-page-objects-guide.md with images * add docs/selene-cheetsheet.md * edit mkdocs.yml to include new articles * edit according to review
- Loading branch information
1 parent
0b6e099
commit f7b9a70
Showing
29 changed files
with
1,533 additions
and
0 deletions.
There are no files selected for viewing
Binary file added
BIN
+36.9 KB
docs/assets/images/selene-for-page-objects-guide.md/with-autocomplete-py.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+59.6 KB
docs/assets/images/selene-for-page-objects-guide.md/with-quick-fix-py.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+47.6 KB
docs/assets/images/selene-for-page-objects-guide.md/without-autocomplete-py.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+246 KB
docs/assets/images/selene-in-action-tutorial.md/todomvc-app-inspect.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+386 KB
...e-in-action-tutorial.md/view-page-source-of-todomvc-with-no-todos-in-chrome.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+317 KB
docs/assets/images/selene-quick-start-tutorial.md/autocomplete-browser.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+266 KB
docs/assets/images/selene-quick-start-tutorial.md/autocomplete-condition.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+100 KB
docs/assets/images/selene-quick-start-tutorial.md/autocomplete-selectors.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+284 KB
docs/assets/images/selene-quick-start-tutorial.md/autocomplete-selene-element.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+348 KB
docs/assets/images/selene-quick-start-tutorial.md/collapse-child-element.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+765 KB
docs/assets/images/selene-quick-start-tutorial.md/compose-css-selector.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+684 KB
...assets/images/selene-quick-start-tutorial.md/compose-selector-child-element.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+675 KB
...ssets/images/selene-quick-start-tutorial.md/compose-selector-parent-element.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+307 KB
docs/assets/images/selene-quick-start-tutorial.md/configuring-test-runner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+572 KB
docs/assets/images/selene-quick-start-tutorial.md/context-menu-inspect.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+233 KB
docs/assets/images/selene-quick-start-tutorial.md/context-menu-new-python-file.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.1 MB
docs/assets/images/selene-quick-start-tutorial.md/find-parent-element.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+803 KB
docs/assets/images/selene-quick-start-tutorial.md/html-element-highlighted.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+112 KB
docs/assets/images/selene-quick-start-tutorial.md/new-python-file-created.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+161 KB
docs/assets/images/selene-quick-start-tutorial.md/new-python-file-name.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+203 KB
docs/assets/images/selene-quick-start-tutorial.md/run-test-from-pycharm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+963 KB
docs/assets/images/selene-quick-start-tutorial.md/search-for-html-element.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+257 KB
docs/assets/images/selene-quick-start-tutorial.md/select-attribute.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Basic Selene commands cheatsheet | ||
|
||
## Find elements | ||
|
||
### Basic location | ||
* `browser.element(selector)` – finds element by selector | ||
* `element.element(selector)` – finds inner element inside another element denoted as element (e.g. saved as `element = browser.element(selector)`) | ||
* `element.all(selector)` – finds inner collection of elements | ||
* `browser.all(selector)` – finds collection of elements by selector | ||
|
||
### Filtering collections | ||
* `collection.by(condition)` – filters collection by condition (where `collection` – saved collection, e.g. via `collection = browser.all(selector)`; `condition` – anything from `be.*` or `have.*`) | ||
* `collection.element_by(condition)` – finds element of collection by condition | ||
* `collection[index]` or `collection.element(index)` – selects element from collection by index (there are shortcuts – `.first` for `[0]` and `.second` for `[1]`) | ||
* `collection[start:stop:step]` – makes slice of collection starting from `start`, ending before `stop`, with step `step` (there are shortcuts – `.odd` for `[::2]` and `.even` for `[1::2]`; there is an alias `sliced(start, stop, step)` for `[start:stop:step]`) | ||
|
||
|
||
#### Advanced filtering | ||
|
||
Commands like ... | ||
|
||
* `collection.by_their(selector, condition)` | ||
* `collection.element_by_its(selector, condition)` | ||
* `collection.all(selector)` | ||
* `collection.all_first(selector)` | ||
|
||
... are used less often, and docs about them can be read by diving into their implementation (there are detailed docstrings). Also you can find examples and explanations of these commands in FAQ as an answer to the question “How to find the desired row in the table by condition ...”. | ||
|
||
## Check conditions | ||
|
||
* `(element | collection | browser).should(condition)` – waits until condition is met, and fails if not | ||
* `(element | collection | browser).wait_until(condition)` – waits until condition is met and returns `false` if not, otherwise `true` | ||
* `(element | collection | browser).matching(condition)` – immediately checks condition and returns `false` if not, otherwise `true` | ||
|
||
|
||
## Advanced | ||
|
||
### Acquiring information from elements | ||
|
||
In Selene you cannot just pull out the text or some attribute from the element. This is done on purpose, because Selene aims to promote the implementation of efficient tests. Good tests are those in which the tester knows in advance what will be on the UI at every moment in time, so he does not need to ask the element for its text or the value of a specific attribute, he either knows it, or performs a check through `.should(have.text('something'))` or `.should(have.attribute('data').value('bar'))`. And if you don't know what you have on your UI, then you are writing a crutch (~ workaround) :) And for crutches – Selene adds “extra API”, which is less concise and makes you write crutches more consciously. For these crutches, the following commands may be useful ... | ||
|
||
* `element.locate()` – will return a clean Selenium WebDriver WebElement, from which you can then get custom attributes, for example `element.locate().get_attribute('src')` | ||
* `element()` – shortcut to `.locate()`, so in real code it may look like `browser.element('#foo')().get_attribute('src')` | ||
* `element.get(query.*)` – waits for the command-query to be executed on the element and returns the result, for example: `browser.element('#foo').get(query.attribute('src'))`, unlike `browser.element('#foo').locate().get_attribute('src')` – waits for the element to appear at least in the DOM and returns the value of the `'src'` attribute of this element | ||
* `collection.locate()` or `collection()` – will return a list of clean WebElements | ||
* `collection.get(query.*)` – there is also, if you find a request for working specifically with a collection among `*` | ||
* `browser.get(query.*)` – there is also, for example `browser.get(query.title)` should return the title of the page (the text inside the `title` tag inside the HTML) | ||
|
||
|
||
### Extra commands on elements | ||
|
||
* `(element | collection | browser).perform(command.*)` – waits for the command to be executed, for example `browser.element('#approve').perform(command.js.click)` or `browser.all('.addvertisment').perform(command.js.remove)` |
Oops, something went wrong.