author | Henrik Skupin <mail@hskupin.info> |
Fri, 08 Jun 2018 15:52:15 +0200 | |
changeset 421948 | 2140cc056ad0178c9083ef28ef45d76136c0fd5d |
parent 421947 | 0cae8574be4c81c256d63a889b49c3da0cb5e380 |
child 421949 | e8cc844125d523b0d1b944d5bea9a3c031a283c8 |
push id | 34110 |
push user | cbrindusan@mozilla.com |
push date | Fri, 08 Jun 2018 21:51:53 +0000 |
treeherder | mozilla-central@54c9df81e008 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | whimboo, doc |
bugs | 1467509 |
milestone | 62.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/testing/marionette/client/docs/interactive.rst +++ b/testing/marionette/client/docs/interactive.rst @@ -1,55 +1,52 @@ Using the Client Interactively ============================== Once you installed the client and have Marionette running, you can fire up your favourite interactive python environment and start playing with Marionette. Let's use a typical python shell: .. parsed-literal:: - python First, import Marionette: .. parsed-literal:: from marionette_driver.marionette import Marionette Now create the client for this session. Assuming you're using the default port on a Marionette instance running locally: .. parsed-literal:: - client = Marionette(host='localhost', port=2828) client.start_session() This will return some id representing your session id. Now that you've established a connection, let's start doing interesting things: .. parsed-literal:: - - client.execute_script("alert('o hai there!');") - -You should now see this alert pop up! How exciting! Okay, let's do -something practical. Close the dialog and try this: - -.. parsed-literal:: - client.navigate("http://www.mozilla.org") Now you're at mozilla.org! You can even verify it using the following: .. parsed-literal:: client.get_url() -You can even find an element and click on it. Let's say you want to get +You can execute Javascript code in the scope of the web page: + +.. parsed-literal:: + client.execute_script("return window.document.title;") + +This will you return the title of the web page as set in the head section +of the HTML document. + +Also you can find elements and click on those. Let's say you want to get the first link: .. parsed-literal:: from marionette_driver import By first_link = client.find_element(By.TAG_NAME, "a") first_link now holds a reference to the first link on the page. You can click it: .. parsed-literal:: first_link.click() -