Python noobin’

Ya, I’m a python noob.  Thanks to mdas and njpark I learned about import pdb.

Basically I placed an import pdb line at the top and pdb.set_trace() where I want to stop.  ( see https://docs.python.org/2/library/pdb.html might be helpful, especially the section 26.3 )

import pdb

from gaiatest import GaiaTestCase
from gaiatest.apps.search.app import Search
from gaiatest.apps.system.regions.activities import Activities
from gaiatest.apps.system.regions.cards_view import CardsView


class TestBrowserWindows(GaiaTestCase):

    def setUp(self):
        GaiaTestCase.setUp(self)
        self.connect_to_local_area_network()
        self.apps.set_permission_by_url(Search.manifest_url, 'geolocation', 'deny')

        self.test_url = self.marionette.absolute_url('mozilla.html')

    def test_browser_menu_windows(self):
        search = Search(self.marionette)
        search.launch()
        browser = search.go_to_url(self.test_url)

        browser.switch_to_chrome()
        browser.tap_menu_button()
        activities = Activities(self.marionette)
        activities.tap_new_window()

        pdb.set_trace()
        browser.tap_windows_button()

        cardsview = CardsView(self.marionette)
        self.assertTrue(cardsview.is_cards_view_displayed)

This way I can debug my code, using commands such as:

<object>.__dict__
dir(<object>)

ie. I can do something like browser.__dict__ or dir(browser)

It helped out a lot.

PS : I really ❤ Pycharm

Advertisements

About shizen008

Breaking things and getting in trouble for it since '74. Disclaimer: I am not responsible if I make your head explode reading this blog! The writings here are my own expression and not of any companies. I currently work on being a QA for B2G aka Firefox OS
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s