PageRenderTime 156ms CodeModel.GetById 44ms RepoModel.GetById 0ms app.codeStats 0ms

/pyccuracy/webdriver_browser_driver.py

https://github.com/bardusco/pyccuracy
Python | 128 lines | 81 code | 37 blank | 10 comment | 3 complexity | 1898995d8f5af7a37d95a3784eb1fda3 MD5 | raw file
Possible License(s): CC-BY-SA-3.0
  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. def __init__(self, browser_to_run, tests_dir):
  16. super(type(self), self).__init__(browser_to_run, tests_dir)
  17. self.__port__ = 8888
  18. self.__host__ = 'localhost'
  19. def resolve_element_key(self, context, element_type, element_key):
  20. raise NotImplementedError
  21. def __wait_for_server_to_start(self):
  22. server_started = False
  23. while server_started == False:
  24. server_started = self.__is_server_started()
  25. time.sleep(2)
  26. def __is_server_started(self):
  27. timeout = urllib2.socket.getdefaulttimeout()
  28. try:
  29. urllib2.socket.setdefaulttimeout(5)
  30. url = "http://%s:%s/" % (self.__host, self.__port)
  31. request = urllib2.urlopen(url)
  32. server_started = True
  33. request.close()
  34. except IOError, e:
  35. server_started = False
  36. urllib2.socket.setdefaulttimeout(timeout)
  37. return server_started
  38. def start_test(self, url = "http://www.someurl.com"):
  39. raise NotImplementedError
  40. def page_open(self, url):
  41. raise NotImplementedError
  42. def type(self, input_selector, text):
  43. raise NotImplementedError
  44. def click_element(self, element_selector):
  45. raise NotImplementedError
  46. def is_element_visible(self, element_selector):
  47. raise NotImplementedError
  48. def wait_for_page(self, timeout = 20000):
  49. raise NotImplementedError
  50. def get_title(self):
  51. raise NotImplementedError
  52. def is_element_enabled(self, element):
  53. raise NotImplementedError
  54. def checkbox_is_checked(self, checkbox_selector):
  55. raise NotImplementedError
  56. def checkbox_check(self, checkbox_selector):
  57. raise NotImplementedError
  58. def checkbox_uncheck(self, checkbox_selector):
  59. raise NotImplementedError
  60. def get_selected_index(self, element_selector):
  61. raise NotImplementedError
  62. def get_selected_value(self, element_selector):
  63. raise NotImplementedError
  64. def get_selected_text(self, element_selector):
  65. raise NotImplementedError
  66. def get_element_text(self, element_selector):
  67. raise NotImplementedError
  68. def get_element_markup(self, element_selector):
  69. raise NotImplementedError
  70. def select_option_by_index(self, element_selector, index):
  71. raise NotImplementedError
  72. def select_option_by_value(self, element_selector, value):
  73. raise NotImplementedError
  74. def select_option_by_text(self, element_selector, text):
  75. raise NotImplementedError
  76. def __select_option(self, element_selector, option_selector, option_value):
  77. raise NotImplementedError
  78. def get_link_href(self, link_selector):
  79. raise NotImplementedError
  80. def get_image_src(self, image_selector):
  81. raise NotImplementedError
  82. def get_link_text(self, link_selector):
  83. raise NotImplementedError
  84. def mouseover_element(self, element_selector):
  85. raise NotImplementedError
  86. def is_element_empty(self, element_selector):
  87. raise NotImplementedError
  88. def stop_test(self):
  89. raise NotImplementedError
  90. def __get_attribute_value(self, element, attribute):
  91. raise NotImplementedError