/pyccuracy/webdriver_browser_driver.py

https://github.com/kenjiyamamoto/pyccuracy · Python · 130 lines · 82 code · 38 blank · 10 comment · 3 complexity · 6cd22d2bb09735b3cb8580d6c9e3f828 MD5 · raw file

  1. # -*- coding: utf-8 -*-
  2. # Licensed under the Open Software License ("OSL") v. 3.0 (the "License");
  3. # you may not use this file except in compliance with the License.
  4. # You may obtain a copy of the License at
  5. # http://www.opensource.org/licenses/osl-3.0.php
  6. # Unless required by applicable law or agreed to in writing, software
  7. # distributed under the License is distributed on an "AS IS" BASIS,
  8. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  9. # See the License for the specific language governing permissions and
  10. # limitations under the License.
  11. import time
  12. import urllib2
  13. from browser_driver import *
  14. class WebdriverBrowserDriver(BrowserDriver):
  15. __not_implemented_exception_message = "This method has not been implemented"
  16. def __init__(self, browser_to_run, tests_dir):
  17. super(type(self), self).__init__(browser_to_run, tests_dir)
  18. self.__port__ = 8888
  19. self.__host__ = 'localhost'
  20. def resolve_element_key(self, context, element_type, element_key):
  21. raise ExceptionNotImplemented(self.__not_implemented_exception_message)
  22. def __wait_for_server_to_start(self):
  23. server_started = False
  24. while server_started == False:
  25. server_started = self.__is_server_started()
  26. time.sleep(2)
  27. def __is_server_started(self):
  28. timeout = urllib2.socket.getdefaulttimeout()
  29. try:
  30. urllib2.socket.setdefaulttimeout(5)
  31. url = "http://%s:%s/" % (self.__host, self.__port)
  32. request = urllib2.urlopen(url)
  33. server_started = True
  34. request.close()
  35. except IOError, e:
  36. server_started = False
  37. urllib2.socket.setdefaulttimeout(timeout)
  38. return server_started
  39. def start_test(self, url = "http://www.someurl.com"):
  40. raise ExceptionNotImplemented(self.__not_implemented_exception_message)
  41. def page_open(self, url):
  42. raise ExceptionNotImplemented(self.__not_implemented_exception_message)
  43. def type(self, input_selector, text):
  44. raise ExceptionNotImplemented(self.__not_implemented_exception_message)
  45. def click_element(self, element_selector):
  46. raise ExceptionNotImplemented(self.__not_implemented_exception_message)
  47. def is_element_visible(self, element_selector):
  48. raise ExceptionNotImplemented(self.__not_implemented_exception_message)
  49. def wait_for_page(self, timeout = 20000):
  50. raise ExceptionNotImplemented(self.__not_implemented_exception_message)
  51. def get_title(self):
  52. raise ExceptionNotImplemented(self.__not_implemented_exception_message)
  53. def is_element_enabled(self, element):
  54. raise ExceptionNotImplemented(self.__not_implemented_exception_message)
  55. def checkbox_is_checked(self, checkbox_selector):
  56. raise ExceptionNotImplemented(self.__not_implemented_exception_message)
  57. def checkbox_check(self, checkbox_selector):
  58. raise ExceptionNotImplemented(self.__not_implemented_exception_message)
  59. def checkbox_uncheck(self, checkbox_selector):
  60. raise ExceptionNotImplemented(self.__not_implemented_exception_message)
  61. def get_selected_index(self, element_selector):
  62. raise ExceptionNotImplemented(self.__not_implemented_exception_message)
  63. def get_selected_value(self, element_selector):
  64. raise ExceptionNotImplemented(self.__not_implemented_exception_message)
  65. def get_selected_text(self, element_selector):
  66. raise ExceptionNotImplemented(self.__not_implemented_exception_message)
  67. def get_element_text(self, element_selector):
  68. raise ExceptionNotImplemented(self.__not_implemented_exception_message)
  69. def get_element_markup(self, element_selector):
  70. raise ExceptionNotImplemented(self.__not_implemented_exception_message)
  71. def select_option_by_index(self, element_selector, index):
  72. raise ExceptionNotImplemented(self.__not_implemented_exception_message)
  73. def select_option_by_value(self, element_selector, value):
  74. raise ExceptionNotImplemented(self.__not_implemented_exception_message)
  75. def select_option_by_text(self, element_selector, text):
  76. raise ExceptionNotImplemented(self.__not_implemented_exception_message)
  77. def __select_option(self, element_selector, option_selector, option_value):
  78. raise ExceptionNotImplemented(self.__not_implemented_exception_message)
  79. def get_link_href(self, link_selector):
  80. raise ExceptionNotImplemented(self.__not_implemented_exception_message)
  81. def get_image_src(self, image_selector):
  82. raise ExceptionNotImplemented(self.__not_implemented_exception_message)
  83. def get_link_text(self, link_selector):
  84. raise ExceptionNotImplemented(self.__not_implemented_exception_message)
  85. def mouseover_element(self, element_selector):
  86. raise ExceptionNotImplemented(self.__not_implemented_exception_message)
  87. def is_element_empty(self, element_selector):
  88. raise ExceptionNotImplemented(self.__not_implemented_exception_message)
  89. def stop_test(self):
  90. raise ExceptionNotImplemented(self.__not_implemented_exception_message)
  91. def __get_attribute_value(self, element, attribute):
  92. raise ExceptionNotImplemented(self.__not_implemented_exception_message)