1

Hi I have a Django form where one field is populated depending on the selection of a previous field. This is working fine when manually tested but I'm hitting a bump when testing with selenium.

Here is the failing test:

# --- functional tests --- #
class ProjectFormsTest(LiveServerTestCase):
    def setUp(self):
        self.browser = webdriver.Firefox()
        self.browser.implicitly_wait(3)

    def tearDown(self):
        self.browser.quit()

    def test_project_info_form(self):
        ...        
        wind = self.browser.find_element_by_id('id_wind_speed')
        self.assertEquals('85', wind.text)

So, I can see selenium load up the browser and the field populates as expected. I'm guessing the root of the problem is that .text is not the correct attribute for a text input form field, as it is returning u''.

Anyone know what is the correct way?

Any help much appreciated.

2
  • wind.get_attribute('value') ? Commented Nov 13, 2012 at 22:14
  • Ha - that's it! I tried wind.get_attribute() AND wind.value. If you post an answer I'll accept it. Commented Nov 13, 2012 at 22:21

1 Answer 1

4

Converted comment:

Use wind.get_attribute('value') to get the value attribute of that element.

From this docs page.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.