Django с салатом и осколком открывает браузер, но ничего не показывает - PullRequest
1 голос
/ 14 сентября 2011

Я пробую свои силы на салате с осколком.У меня есть приложение Django, которое хорошо настроено, никаких проблем с этим.Когда я пытаюсь запустить салат, с шагом, который «должен» посетить 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 "abc@def.gih"

Вот мой 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 "dsfdf@safsdfsd"       # 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)

Пожалуйста, кто-нибудь может мне помочь в этом?

Ответы [ 2 ]

3 голосов
/ 11 января 2012

вы не много объясняете, но, возможно, попробуйте следующее

    world.browser.find_by_id(field).fill(value)
0 голосов
/ 20 июля 2012

У меня была такая же проблема. Запись:

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

от

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

и все будет хорошо!

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...