我想我的手與生菜分裂。我有一個配置良好的django應用程序,沒有問題。當我嘗試運行生菜時,「應該」訪問瀏覽器中的一個URL時,它不會返回任何錯誤,但它不會顯示該頁面。Django與生菜和分裂,打開瀏覽器,但不顯示任何東西
這裏是我的.feature文件:
Feature: A test
Scenario: User enters email, ajax will check if it exists
When I go to the "/home/login/" URL
Then I fill in "#id_email" with "[email protected]"
這裏是我的steps.py
from lettuce import *
from lettuce.django import django_url
from lxml import html
from django.test.client import Client
from nose.tools import assert_equals
from splinter.browser import Browser
from django.test.utils import setup_test_environment, teardown_test_environment
from django.core.management import call_command
from django.db import connection
from django.conf import settings
@before.all
def set_browser():
setup_test_environment()
world.browser = Browser('firefox')
@step(u'I go to the "(.*)" URL')
def i_go_to_the_url(step, url):
world.response = world.browser.visit(django_url(url))
@step(u'I fill in "(.*)" with "(.*)"')
def i_fill_in(step, field, value):
world.browser.fill(field, value)
它打開瀏覽器,瀏覽器不會顯示任何東西,但測試成功,並第二種情況失敗,出現以下錯誤:
Feature: A test # candidate/feature/index.feature:1
Scenario: User enters email, ajax will check if it exists # candidate/feature/index.feature:3
When I go to the "/home/login/" URL # home/feature/index-steps.py:29
Then I fill in "email" with "[email protected]" # home/feature/index-steps.py:39
Traceback (most recent call last):
File "/usr/local/lib/python2.6/dist-packages/lettuce/core.py", line 117, in __call__
ret = self.function(self.step, *args, **kw)
File "********/candidate/feature/index-steps.py", line 40, in i_fill_in
world.browser.fill(field, value)
File "/usr/local/lib/python2.6/dist-packages/splinter/driver/webdriver/__init__.py", line 240, in fill
field.value = value
File "/usr/local/lib/python2.6/dist-packages/splinter/driver/webdriver/__init__.py", line 306, in _set_value
self._element.clear()
AttributeError: 'NoneType' object has no attribute 'clear'
1 feature (0 passed)
1 scenario (0 passed)
2 steps (1 failed, 1 passed)
(finished within 15 seconds)
請任何人都可以幫我解決這個問題嗎?
萬一它幫助別人,你傳遞一個ID,所以你需要find_by_id。如果您想使用原始填充方法,則需要傳入字段名稱。 –