cobrateam / cobrateam/splinter
DjangoClientElement does not implement most of the methods of ElementAPI
- Dominant language
- Python
- Stars
- 2.7k
- Forks
- 511
- PR merge metrics
- No merged PRs in 30d
Description
First thing first: Thanks for your time.
Your docs: [Django driver](http://splinter.cobrateam.info/docs/drivers/django.html)
Missing (at least):
- click(self)
- check(self)
- uncheck(self)
- checked(self)
My code (snippet):
```
def login(self, name_or_email, password, confirmation_url=None, remember=False, idempotent=False):
"""
Sign-in after having confirmed the e-mail address with the optional confirmation URL.
Set idempotent to True to skip sign-in if the user is currently logged-in. This not guarantee that the current
user is the expected user.
"""
if not idempotent or not self.is_logged:
if confirmation_url:
self.browser.visit(confirmation_url)
time.sleep(1) # FIXME Strangely this delay is necessary otherwise the button is not clicked
self.browser.find_by_id('confirm_btn').click()
if not self.is_login_page:
self.assertIsNone(confirmation_url, 'Confirmation URL is invalid: %s' % confirmation_url)
self.browser.click_link_by_partial_href('login')
self.browser.find_by_id('id_login').fill(name_or_email)
self.browser.find_by_id('id_password').fill(password)
remember_checkbox = self.browser.find_by_id('id_remember')
remember_checkbox.check() if remember else remember_checkbox.uncheck()
self.browser.find_by_id('login_btn').click()
```
The error (using splinter from master):
```
======================================================================
ERROR: test_bad_login_username_does_not_work (server.cloudncode_base.tests.test_live.AccountWUILiveTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/ubuntu/cloudncode_test/server/cloudncode_base/lib/test/live/wui/account.py", line 28, in test_bad_login_username_does_not_work
self.login('hacker', 'I_r0cks')
File "/home/ubuntu/cloudncode_test/server/cloudncode_base/lib/test/live/base.py", line 171, in login
remember_checkbox.check() if remember else remember_checkbox.uncheck()
File "/home/ubuntu/splinter/splinter/driver/__init__.py", line 494, in uncheck
raise NotImplementedError
NotImplementedError
```
I don't know if I implemented it well because I am unable to go further (do not know how to implement click) but I guess the following works:
```
def check(self):
if not self.checked:
self._element.click()
def uncheck(self):
if self.checked:
self._element.click()
@property
def checked(self):
return self._element.is_selected()
selected = checked
```
Remark: DjangoClientElement._element is an instance class [HtmlElement](http://lxml.de/api/lxml.html.HtmlElement-class.html) from [lxml](https://github.com/lxml/lxml)
Please help me,
Thanks.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.