这是追溯:
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'
这是我的测试python文件(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_()
答案 0 :(得分:1)
您没有做一些必要的设置:
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__])
这应该在您尝试实例化WindmillTestClient
之前发生。