blob: e72d2549bd02b4fe0f61a7280a7748ebbee26470 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
Debugging
=========
.. py:currentmodule:: marionette
Sometimes when working with Marionette you'll run into unexpected behaviour and
need to do some debugging. This page outlines some of the Marionette methods
that can be useful to you.
Please note that the best tools for debugging are the `ones that ship with
Gecko`_. This page doesn't describe how to use those with Marionette. Also see
a related topic about `using the debugger with Marionette`_ on MDN.
.. _ones that ship with Gecko: https://developer.mozilla.org/en-US/docs/Tools
.. _using the debugger with Marionette: https://developer.mozilla.org/en-US/docs/Marionette/Debugging
Storing Logs on the Server
~~~~~~~~~~~~~~~~~~~~~~~~~~
By calling `~Marionette.log` it is possible to store a message on the server.
Logs can later be retrieved using `~Marionette.get_logs`. For example::
try:
marionette.log("Sending a click event") # logged at INFO level
elem.click()
except:
marionette.log("Something went wrong!", "ERROR")
print(marionette.get_logs())
Disclaimer: Example for illustrative purposes only, don't actually hide
tracebacks like that!
Seeing What's on the Page
~~~~~~~~~~~~~~~~~~~~~~~~~
Sometimes it's difficult to tell what is actually on the page that is being
manipulated. Either because it happens too fast, the window isn't big enough or
you are manipulating a remote server! There are two methods that can help you
out. The first is `~Marionette.screenshot`::
marionette.screenshot() # takes screenshot of entire frame
elem = marionette.find_element(By.ID, 'some-div')
marionette.screenshot(elem) # takes a screenshot of only the given element
Sometimes you just want to see the DOM layout. You can do this with the
`~Marionette.page_source` property. Note that the page source depends on the
context you are in::
print(marionette.page_source)
marionette.set_context('chrome')
print(marionette.page_source)
|