Mensagem de Erro completa:
ERROR: test_campo_de_busca (setup.tests.AnimaisTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Users\magal\aplicacoes em django\desenvolvimento guiado por testes\setup\tests.py", line 25, in test_campo_de_busca
busca_animal_input = self.browser.find_element(By.CSS_SELECTOR, 'input#buscar-animal')
File "C:\Users\magal\aplicacoes em django\desenvolvimento guiado por testes\alura_testes\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 855, in find_element
return self.execute(Command.FIND_ELEMENT, {
File "C:\Users\magal\aplicacoes em django\desenvolvimento guiado por testes\alura_testes\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 428, in execute
self.error_handler.check_response(response)
File "C:\Users\magal\aplicacoes em django\desenvolvimento guiado por testes\alura_testes\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 243, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":"input#buscar-animal"}
(Session info: chrome=104.0.5112.102)
Stacktrace:
Backtrace:
Ordinal0 [0x00B078B3+2193587]
Ordinal0 [0x00AA0681+1771137]
Ordinal0 [0x009B41A8+803240]
Ordinal0 [0x009E24A0+992416]
Ordinal0 [0x009E273B+993083]
Ordinal0 [0x00A0F7C2+1177538]
Ordinal0 [0x009FD7F4+1103860]
Ordinal0 [0x00A0DAE2+1170146]
Ordinal0 [0x009FD5C6+1103302]
Ordinal0 [0x009D77E0+948192]
Ordinal0 [0x009D86E6+952038]
GetHandleVerifier [0x00DB0CB2+2738370]
GetHandleVerifier [0x00DA21B8+2678216]
GetHandleVerifier [0x00B917AA+512954]
GetHandleVerifier [0x00B90856+509030]
Ordinal0 [0x00AA743B+1799227]
Ordinal0 [0x00AABB68+1817448]
Ordinal0 [0x00AABC55+1817685]
Ordinal0 [0x00AB5230+1856048]
BaseThreadInitThunk [0x77C4FA29+25]
RtlGetAppContainerNamedObjectPath [0x77EB7A9E+286]
RtlGetAppContainerNamedObjectPath [0x77EB7A6E+238]
----------------------------------------------------------------------
Ran 3 tests in 8.835s
FAILED (errors=1)
Destroying test database for alias 'default'...
(alura_testes)
Codigo:
from django.test import LiveServerTestCase
from selenium import webdriver
from selenium.webdriver.common.by import By
class AnimaisTestCase(LiveServerTestCase):
def setUp(self):
self.browser = webdriver.Chrome(r'C:\Users\magal\aplicacoes em django\desenvolvimento guiado por testes\chromedriver.exe')
def tearDown(self):
self.browser.quit()
def test_pesquisa_animal(self):
"""
Teste que Verifica se foi encontrado algum animal da pesquisa
"""
home_page = self.browser.get(self.live_server_url + "/")
brand_element = self.browser.find_element(By.CSS_SELECTOR, '.navbar')
self.assertEqual('Busca Animais', brand_element.text)
def test_campo_de_busca(self):
busca_animal_input = self.browser.find_element(By.CSS_SELECTOR, 'input#buscar-animal')
self.assertEqual(busca_animal_input.get_attribute('placeholder'), 'Exemplo: leão')