forked from cobrateam/splinter
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'remote' of github.com:cobrateam/splinter
- Loading branch information
Showing
3 changed files
with
150 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
import subprocess | ||
|
||
from selenium.webdriver import Remote | ||
from splinter.driver.webdriver import BaseWebDriver, WebDriverElement as BaseWebDriverElement | ||
from splinter.cookie_manager import CookieManagerAPI | ||
|
||
|
||
class WebDriver(BaseWebDriver): | ||
|
||
def __init__(self, server='localhost', port=4444): | ||
self.old_popen = subprocess.Popen | ||
|
||
self._patch_subprocess() | ||
dest = 'http://%s:%s/wd/hub' % (server, port) | ||
self.driver = Remote(dest, {}) | ||
self._unpatch_subprocess() | ||
|
||
self.element_class = WebDriverElement | ||
|
||
self._cookie_manager = CookieManagerAPI() | ||
|
||
super(WebDriver, self).__init__() | ||
|
||
|
||
class WebDriverElement(BaseWebDriverElement): | ||
|
||
def mouse_over(self): | ||
""" | ||
Remote Firefox doesn't support mouseover. | ||
""" | ||
raise NotImplementedError("Remote Firefox doesn't support mouse over") | ||
|
||
def mouse_out(self): | ||
""" | ||
Remote Firefox doesn't support mouseout. | ||
""" | ||
raise NotImplementedError("Remote Firefox doesn't support mouseout") | ||
|
||
def double_click(self): | ||
""" | ||
Remote Firefox doesn't support doubleclick. | ||
""" | ||
raise NotImplementedError("Remote Firefox doesn't support doubleclick") | ||
|
||
def right_click(self): | ||
""" | ||
Remote Firefox doesn't support right click' | ||
""" | ||
raise NotImplementedError("Remote Firefox doesn't support right click") | ||
|
||
def drag_and_drop(self, droppable): | ||
""" | ||
Remote Firefox doesn't support drag and drop | ||
""" | ||
raise NotImplementedError("Remote Firefox doesn't support drag an drop") | ||
|
||
mouseover = mouse_over | ||
mouseout = mouse_out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
try: | ||
import unittest2 as unittest | ||
except ImportError: | ||
import unittest | ||
|
||
from splinter import Browser | ||
from fake_webapp import EXAMPLE_APP | ||
from base import WebDriverTests | ||
|
||
import sys | ||
|
||
|
||
@unittest.skipUnless('-remote' in sys.argv, 'Skipping the remote webdriver tests') | ||
class RemoteBrowserTest(WebDriverTests, unittest.TestCase): | ||
|
||
@classmethod | ||
def setUpClass(cls): | ||
cls.browser = Browser("remote") | ||
|
||
@classmethod | ||
def tearDownClass(cls): | ||
cls.browser.quit() | ||
|
||
def setUp(self): | ||
self.browser.visit(EXAMPLE_APP) | ||
|
||
def test_mouse_over(self): | ||
"Remote should not support mouseover" | ||
with self.assertRaises(NotImplementedError): | ||
self.browser.find_by_id('visible').first.mouse_over() | ||
|
||
def test_mouse_out(self): | ||
"Remote should not support mouseout" | ||
with self.assertRaises(NotImplementedError): | ||
self.browser.find_by_id('visible').first.mouse_out() | ||
|
||
def test_double_click(self): | ||
"Remote should not support double_click" | ||
with self.assertRaises(NotImplementedError): | ||
self.browser.find_by_id('visible').double_click() | ||
|
||
def test_right_click(self): | ||
"Remote should not support right_click" | ||
with self.assertRaises(NotImplementedError): | ||
self.browser.find_by_id('visible').right_click() | ||
|
||
def test_drag_and_drop(self): | ||
"Remote should not support drag_and_drop" | ||
with self.assertRaises(NotImplementedError): | ||
droppable = self.browser.find_by_css('.droppable') | ||
self.browser.find_by_css('.draggable').drag_and_drop(droppable) | ||
|
||
def test_mouseover_should_be_an_alias_to_mouse_over_and_be_deprecated(self): | ||
"Remote should not support mouseover" | ||
with self.assertRaises(NotImplementedError): | ||
self.browser.find_by_id('visible').mouseover() | ||
|
||
def test_mouseout_should_be_an_alias_to_mouse_out_and_be_deprecated(self): | ||
"Remote should not support mouseout" | ||
with self.assertRaises(NotImplementedError): | ||
self.browser.find_by_id('visible').mouseout() | ||
|
||
def test_create_and_access_a_cookie(self): | ||
"Remote should not support cookies" | ||
with self.assertRaises(NotImplementedError): | ||
self.browser.cookies.add({'sha': 'zam'}) | ||
|
||
def test_create_some_cookies_and_delete_them_all(self): | ||
"Remote should not support cookies" | ||
with self.assertRaises(NotImplementedError): | ||
self.browser.cookies.delete() | ||
|
||
def test_create_and_delete_a_cookie(self): | ||
"Remote should not support cookies" | ||
with self.assertRaises(NotImplementedError): | ||
self.browser.cookies.delete('cookie') | ||
|
||
def test_create_and_delete_many_cookies(self): | ||
"Remote should not support cookies" | ||
with self.assertRaises(NotImplementedError): | ||
self.browser.cookies.delete('cookie', 'notacookie') | ||
|
||
def test_try_to_destroy_an_absent_cookie_and_nothing_happens(self): | ||
"Remote should not support cookies" | ||
with self.assertRaises(NotImplementedError): | ||
self.browser.cookies.delete('mwahahahaha') |