TDD/CSS & HTML testing issue

Posted May 13, 2020 740 views
PythonDjangoVS Code

Hello everyone - I just ran into another issue related to CSS selector especially ’.has-error’ I still cant find a solution. Anyone here ever dealt with this issue before? pls kindly help. I am stuck at this point below:

“‘selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: .has-error”’

Related code between my template/selenium:

Python part:

self.wait_for(lambda: self.assertEqual(self.browser.find_element_by_css_selector('.has-error').text,
"You can't have an empty list item"))

html part:

            <div class="form-group has-error">
                    <span class="help-block">{{ error }}</span>
     {% endif %}

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer

Never used it but most likely the selector returns a list and thus does not have a text field.