Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Add type="tel" support for fill_form #277

Merged
merged 4 commits into from Jan 20, 2014

Conversation

Projects
None yet
2 participants
Contributor

victorhooi commented Jan 14, 2014

No description provided.

Owner

andrewsmedina commented Jan 14, 2014

I think that a best way is to add a fallback. When the type is not one of the expected types splinter executes:

 element.value = value
Contributor

victorhooi commented Jan 14, 2014

@andrewsmedina Do you mean like that? (See commit just now).

Do you still want to leave "tel" as an explicit input type as well?

Owner

andrewsmedina commented Jan 14, 2014

@victorhooi the commit is good to me. Can you add tests for these changes? If you need help, let me know.

Contributor

victorhooi commented Jan 14, 2014

@andrewsmedina You're absolutely right - I should add tests.

I couldn't seem to find anything in the README about running tests - however, I figured I'd try with run_tests.py - that seemed to spawn up around eight Firefox/Chrome windows:

bEx-m53-2:splinter victor$ python run_tests.py
.....E...................................................................................................................................................................................................F.F...................................................F..................
.......................................................................................................F.F........................................................................................................................................................................
....F.F...ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssE
======================================================================
ERROR: test_zope_testbrowser_should_be_able_to_change_user_agent (test_browser.BrowserTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/victor/code/splinter/tests/test_browser.py", line 66, in test_zope_testbrowser_should_be_able_to_change_user_agent
    self.assertTrue(self.browser_can_change_user_agent('zope.testbrowser'))
  File "/Users/victor/code/splinter/tests/test_browser.py", line 35, in browser_can_change_user_agent
    browser = Browser(driver_name=webdriver, user_agent="iphone")
  File "/Users/victor/code/splinter/splinter/browser.py", line 45, in Browser
    raise DriverNotFoundError("No driver for %s" % driver_name)
DriverNotFoundError: No driver for zope.testbrowser
======================================================================
FAIL: test_take_screenshot (test_webdriver_chrome.ChromeBrowserTest)
should take a screenshot of the current page
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/victor/code/splinter/tests/screenshot.py", line 12, in test_take_screenshot
    self.assertTrue('tmp' in filename)
AssertionError: False is not true
...

----------------------------------------------------------------------
Ran 732 tests in 965.660s

FAILED (failures=7, errors=2, skipped=174)

The Chrome/Firefox windows didn't close after the tests finished (this is on OSX) - although is that by design?

Most of the failures seem to be related to either the missing Zope WebDrive on my system, or some issue with taking screenshots? Not sure how to fix the screenshot error.

Also, is there any way to run a single test case easily, if you don't want to have to run the whole test suite (which takes around 15 minutes).

Also, just to clarify - I'll be adding some form elements to here:

https://github.com/cobrateam/splinter/blob/master/tests/static/index.html

and then add the appropriate test case to:

https://github.com/cobrateam/splinter/blob/master/tests/form_elements.py

Also, is your preference to leave in "tel" as an explicit input type? E.g.

if element['type'] in ['text', 'password', 'tel'] or element.tag_name == 'textarea':

Or would you prefer it just as a fallback?

else:
    element.value = value

(My preference is for former).

Cheers,
Victor

Owner

andrewsmedina commented Jan 15, 2014

@victorhooi you can use make test to run the tests.

Contributor

victorhooi commented Jan 17, 2014

@andrewsmedina Sorry to bother you again - I added some tests and ran make tests.

However, the screenshot ones still failed (this seems to be unrelated to my change?):

FAIL: test_take_screenshot (test_webdriver_firefox.FirefoxBrowserTest)
should take a screenshot of the current page
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/victor/code/splinter_fork/splinter/tests/screenshot.py", line 12, in test_take_screenshot
    self.assertTrue('tmp' in filename)
AssertionError: False is not true

And the new tests I ran seemed to fail on the Zope part?

======================================================================
FAIL: test_can_fill_tel_text_field (test_zopetestbrowser.ZopeTestBrowserDriverTest)
should provide a way to change a tel field value
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/victor/code/splinter_fork/splinter/tests/form_elements.py", line 123, in test_can_fill_tel_text_field
    self.assertEqual(new_telephone, value)
AssertionError: '555-0042' != ''

======================================================================
FAIL: test_can_fill_unknown_text_field (test_zopetestbrowser.ZopeTestBrowserDriverTest)
should provide a way to change a unknown text field type that isn't specifically defined
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/victor/code/splinter_fork/splinter/tests/form_elements.py", line 130, in test_can_fill_unknown_text_field
    self.assertEqual(new_search_keyword, value)
AssertionError: 'foobar' != ''

I ran the steps manually through the Python shell and it seems ok.

Any thoughts?

Cheers,
Victor

Owner

andrewsmedina commented Jan 17, 2014

It is needed to implement it to zope.testbrowser driver too: https://github.com/cobrateam/splinter/blob/master/splinter/driver/zopetestbrowser.py#L172

Contributor

victorhooi commented Jan 20, 2014

@andrewsmedina Ok, I've just implemented it in the Zopedriver as well - all the tests (except for the screenshot) ones should pass now =).

Owner

andrewsmedina commented Jan 20, 2014

@victorhooi thank you! I will see what happens with the screenshot tests

andrewsmedina added a commit that referenced this pull request Jan 20, 2014

Merge pull request #277 from victorhooi/patch-2
Add type="tel" support for fill_form

@andrewsmedina andrewsmedina merged commit e607a53 into cobrateam:master Jan 20, 2014

1 check failed

default The Travis CI build could not complete due to an error
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment