webelement.py 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. from selenium.webdriver.remote.webelement import WebElement as RemoteWebElement
  18. class FirefoxWebElement(RemoteWebElement):
  19. @property
  20. def anonymous_children(self):
  21. """Retrieve the anonymous children of this element in an XBL
  22. context. This is only available in chrome context.
  23. See the `anonymous content documentation
  24. <https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XBL/XBL_1.0_Reference/Anonymous_Content>`_
  25. on MDN for more information.
  26. """
  27. return self._execute(
  28. "ELEMENT_GET_ANONYMOUS_CHILDREN",
  29. {"value": None})
  30. def find_anonymous_element_by_attribute(self, name, value):
  31. """Retrieve an anonymous descendant with a specified attribute
  32. value. Typically used with an (arbitrary) anonid attribute to
  33. retrieve a specific anonymous child in an XBL binding.
  34. See the `anonymous content documentation
  35. <https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XBL/XBL_1.0_Reference/Anonymous_Content>`_
  36. on MDN for more information.
  37. """
  38. return self._execute(
  39. "ELEMENT_FIND_ANONYMOUS_ELEMENTS_BY_ATTRIBUTE",
  40. {"name": name, "value": value})["value"]