Skip to content

Commit

Permalink
Experiment with selenium testing
Browse files Browse the repository at this point in the history
  • Loading branch information
nomeata committed Mar 21, 2014
1 parent c4f90e8 commit def6e98
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ install:
- sudo apt-get update
- sudo apt-get install python2.7-dev swig libsasl2-dev libssl-dev libpq-dev
- sudo apt-get install openjdk-6-jdk dejagnu checkstyle gcj-jdk jclassinfo
- sudo apt-get install phantomjs
- pip install http://python-subprocess32.googlecode.com/files/subprocess32-3.2.3.tar.gz
- pip install -r requirements.txt

Expand Down
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ django-tinymce>=1.5.2
docutils>=0.10
subprocess32
psycopg2
selenium==2.40.0

2 changes: 1 addition & 1 deletion src/settings/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def __setattr__(self,k,v):

d.ROOT_URLCONF = 'urls'

d.LOGIN_REDIRECT_URL = BASE_PATH + '/tasks/'
d.LOGIN_REDIRECT_URL = 'task_list'

# URL to use when referring to static files located in STATIC_ROOT.
# Example: "/static/" or "http://static.example.com/"
Expand Down
23 changes: 23 additions & 0 deletions src/utilities/TestSuite.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,29 @@ def assertRedirectsToView(self, response, view):
self.assertEquals(resolve(urlparse(url)[2])[0].__name__, view)


from django.test import LiveServerTestCase
from selenium.webdriver.phantomjs.webdriver import WebDriver

class SeleniumTestCase(LiveServerTestCase):
def setUp(self):
super(SeleniumTestCase, self).setUp()
self.selenium = WebDriver()

def tearDown(self):
self.selenium.quit()
super(SeleniumTestCase, self).tearDown()

def loginAsUser(self):
self.selenium.get('%s%s' % (self.live_server_url, '/accounts/login/'))
username_input = self.selenium.find_element_by_name("username")
username_input.send_keys('user')
password_input = self.selenium.find_element_by_name("password")
password_input.send_keys('demo')
self.selenium.find_element_by_xpath('//input[@value="Login"]').click()




from accounts.models import User, Tutorial
from django.contrib.auth.models import Group
from tasks.models import Task
Expand Down

1 comment on commit def6e98

@ifrh
Copy link
Contributor

@ifrh ifrh commented on def6e98 Sep 15, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since 2015 (phantomjs (2.1.1+dfsg-1)) PhantomJS unusable via WebDriver, when installed from official debian or ubuntu repositories, because "Disabled Ghostdriver due to pre-built source-less Selenium blobs."

references:
http://changelogs.ubuntu.com/changelogs/pool/universe/p/phantomjs/phantomjs_2.1.1+dfsg-2/changelog
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=860485
https://bugs.launchpad.net/ubuntu/+source/phantomjs/+bug/1578444
ariya/phantomjs#14424
https://github.com/detro/ghostdriver/issues/473

=========

It should be possible on debian systems to build disabled Ghostdrivers for Phantomjs with a bash-script called tools/import_atoms.sh using Google Closure Compiler .

references:
https://github.com/detro/ghostdriver/issues/473#issuecomment-288412330
https://github.com/detro/ghostdriver#webdriver-atoms

=========

since March 2018 : "Archiving the project PhantomJS : suspending the development"
PhantomJS version 2.1.1 will remain the last known stable release until further notice.

reference:
ariya/phantomjs#15344

Please sign in to comment.