debug.rst (1480B)
1 Debugging 2 ========= 3 4 .. py:currentmodule:: marionette_driver.marionette 5 6 Sometimes when working with Marionette you'll run into unexpected behaviour and 7 need to do some debugging. This page outlines some of the Marionette methods 8 that can be useful to you. 9 10 Please note that the best tools for debugging are the `ones that ship with 11 Gecko`_. This page doesn't describe how to use those with Marionette. Also see 12 a related topic about `using the debugger with Marionette`_ on MDN. 13 14 .. _ones that ship with Gecko: https://developer.mozilla.org/en-US/docs/Tools 15 .. _using the debugger with Marionette: https://developer.mozilla.org/en-US/docs/Marionette/Debugging 16 17 Seeing What's on the Page 18 ~~~~~~~~~~~~~~~~~~~~~~~~~ 19 20 Sometimes it's difficult to tell what is actually on the page that is being 21 manipulated. Either because it happens too fast, the window isn't big enough or 22 you are manipulating a remote server! There are two methods that can help you 23 out. The first is :func:`~Marionette.screenshot`:: 24 25 marionette.screenshot() # takes screenshot of entire frame 26 elem = marionette.find_element(By.ID, 'some-div') 27 marionette.screenshot(elem) # takes a screenshot of only the given element 28 29 Sometimes you just want to see the DOM layout. You can do this with the 30 :attr:`~Marionette.page_source` property. Note that the page source depends on 31 the context you are in:: 32 33 print(marionette.page_source) 34 marionette.set_context('chrome') 35 print(marionette.page_source)