pythonbeautifulsoupwindmill

Windmill AttributeError: 'module' object has no attribute 'settings'


Here is the traceback:

File "./test2.py", line 44, in test_scrape
    client = WindmillTestClient(__name__)
File "/usr/local/lib/python2.7/dist-packages/windmill-1.6-py2.7.egg/windmill/authoring/__init__.py", line 142, in __init__
method_proxy = windmill.tools.make_jsonrpc_client()
File "/usr/local/lib/python2.7/dist-packages/windmill-1.6-py2.7.egg/windmill/tools/__init__.py", line 35, in make_jsonrpc_client
url = urlparse(windmill.settings['TEST_URL'])
AttributeError: 'module' object has no attribute 'settings'

Here is my test python file (test.py):

#!/usr/bin/env python
# Generated by the windmill services transformer
from windmill.authoring import WindmillTestClient
from bs4 import BeautifulSoup

import re, urlparse
from copy import copy



def get_table_info(client):
    """
    Parse HTML page and extract featured image name and link
    """
    # Get Javascript updated HTML page
    client.waits.forElement(xpath=u"//table[@id='trades']",
                        timeout=40000)
    response = client.commands.getPageText()
    assert response['status']
    assert response['result']

    # Create soup from HTML page and get desired information

    soup = BeautifulSoup(response['result'])


    table_info = soup.find("title")
    return table_inf        



def test_scrape():
    client = WindmillTestClient(__name__)
    client.open(url='http://www.google.com')


test_scrape_()

Solution

  • You're not doing some of the necessary setup required:

    from windmill.authoring import setup_module, WindmillTestClient
    from windmill.conf import global_settings
    import sys
    
    global_settings.START_FIREFOX = True # This makes it use Firefox
    setup_module(sys.modules[__name__])
    

    This should occur before you try to instantiate a WindmillTestClient.