2011-09-14 7 views
1

양상추에 양념을 치고 있습니다. 나는 잘 구성된 장고 응용 프로그램을 가지고 있으며 그 문제는 없습니다. 브라우저에서 URL을 방문해야하는 단계와 함께 상추를 실행하려고하면 오류가 반환되지 않지만 페이지가 표시되지 않습니다. 여기 양상추와 가시가있는 장고. 브라우저는 열리지 만 아무 것도 표시되지 않습니다.

내 .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) 

제발 누구든지 도와 줄 수 있습니까?

답변

3

당신은 많은 설명,하지만 어쩌면 나는이 같은 문제를 가지고있는 다음과 같은

world.browser.find_by_id(field).fill(value) 
+0

다른 사람들을 돕는 경우 find_by_id가 필요하므로 ID를 전달합니다. 원래의 채우기 방법을 사용하려면 필드 이름을 전달해야합니다. –

0

을 시도하지 않습니다.

When I go to the "http://0.0.0.0:8000/home/login/" URL 

When I go to the "/home/login/" URL 

의 insted 모든 것이 잘 될 것입니다 : 쓰기!

+0

나는 그것을 또한 시험해 보았다. 일하지 않았어. : –

+1

django_url (...)이 그렇게하고 있습니다. 테스트 서버가 다른 포트에서 시작될 경우 전체 URL을 하드 코딩해서는 안됩니다. –

관련 문제