desired_capabilities.py 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. # Licensed to the Software Freedom Conservancy (SFC) under one
  2. # or more contributor license agreements. See the NOTICE file
  3. # distributed with this work for additional information
  4. # regarding copyright ownership. The SFC licenses this file
  5. # to you under the Apache License, Version 2.0 (the
  6. # "License"); you may not use this file except in compliance
  7. # with the License. You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing,
  12. # software distributed under the License is distributed on an
  13. # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  14. # KIND, either express or implied. See the License for the
  15. # specific language governing permissions and limitations
  16. # under the License.
  17. """
  18. The Desired Capabilities implementation.
  19. """
  20. class DesiredCapabilities(object):
  21. """
  22. Set of default supported desired capabilities.
  23. Use this as a starting point for creating a desired capabilities object for
  24. requesting remote webdrivers for connecting to selenium server or selenium grid.
  25. Usage Example::
  26. from selenium import webdriver
  27. selenium_grid_url = "http://198.0.0.1:4444/wd/hub"
  28. # Create a desired capabilities object as a starting point.
  29. capabilities = DesiredCapabilities.FIREFOX.copy()
  30. capabilities['platform'] = "WINDOWS"
  31. capabilities['version'] = "10"
  32. # Instantiate an instance of Remote WebDriver with the desired capabilities.
  33. driver = webdriver.Remote(desired_capabilities=capabilities,
  34. command_executor=selenium_grid_url)
  35. Note: Always use '.copy()' on the DesiredCapabilities object to avoid the side
  36. effects of altering the Global class instance.
  37. """
  38. FIREFOX = {
  39. "browserName": "firefox",
  40. "marionette": True,
  41. "acceptInsecureCerts": True,
  42. }
  43. INTERNETEXPLORER = {
  44. "browserName": "internet explorer",
  45. "version": "",
  46. "platform": "WINDOWS",
  47. }
  48. EDGE = {
  49. "browserName": "MicrosoftEdge",
  50. "version": "",
  51. "platform": "WINDOWS"
  52. }
  53. CHROME = {
  54. "browserName": "chrome",
  55. "version": "",
  56. "platform": "ANY",
  57. }
  58. OPERA = {
  59. "browserName": "opera",
  60. "version": "",
  61. "platform": "ANY",
  62. }
  63. SAFARI = {
  64. "browserName": "safari",
  65. "version": "",
  66. "platform": "MAC",
  67. }
  68. HTMLUNIT = {
  69. "browserName": "htmlunit",
  70. "version": "",
  71. "platform": "ANY",
  72. }
  73. HTMLUNITWITHJS = {
  74. "browserName": "htmlunit",
  75. "version": "firefox",
  76. "platform": "ANY",
  77. "javascriptEnabled": True,
  78. }
  79. IPHONE = {
  80. "browserName": "iPhone",
  81. "version": "",
  82. "platform": "MAC",
  83. }
  84. IPAD = {
  85. "browserName": "iPad",
  86. "version": "",
  87. "platform": "MAC",
  88. }
  89. ANDROID = {
  90. "browserName": "android",
  91. "version": "",
  92. "platform": "ANDROID",
  93. }
  94. PHANTOMJS = {
  95. "browserName": "phantomjs",
  96. "version": "",
  97. "platform": "ANY",
  98. "javascriptEnabled": True,
  99. }