Bug 1275273 - Make puppeteer framework aware of properties and attributes; r?whimboo draft
authorAndreas Tolfsen <ato@mozilla.com>
Thu, 17 Nov 2016 13:06:37 +0000
changeset 441057 25a2278590a26a39b3088090d9c0376c643d3f62
parent 441056 222ae535fdcd28f5a0687b3099b34052831c3a81
child 441058 adb828762c7c19e2c0f55df55d110c0dc0ad893f
push id36344
push userbmo:ato@mozilla.com
push dateFri, 18 Nov 2016 09:56:50 +0000
reviewerswhimboo
bugs1275273
milestone53.0a1
Bug 1275273 - Make puppeteer framework aware of properties and attributes; r?whimboo Marionette in content context has had non-conflating property vs. attribute behaviour for some time. This makes the puppeteer framework aware of the differences as the same behaviour is enabled for chrome context. MozReview-Commit-ID: KwYpshDKzV4
testing/puppeteer/firefox/firefox_puppeteer/ui/browser/tabbar.py
testing/puppeteer/firefox/firefox_puppeteer/ui/browser/toolbars.py
--- a/testing/puppeteer/firefox/firefox_puppeteer/ui/browser/tabbar.py
+++ b/testing/puppeteer/firefox/firefox_puppeteer/ui/browser/tabbar.py
@@ -57,17 +57,17 @@ class TabBar(UIBaseLib):
     # Properties for helpers when working with the tabs toolbar #
 
     @property
     def selected_index(self):
         """The index of the currently selected tab.
 
         :return: Index of the selected tab.
         """
-        return int(self.toolbar.get_attribute('selectedIndex'))
+        return int(self.toolbar.get_property('selectedIndex'))
 
     @property
     def selected_tab(self):
         """A :class:`Tab` instance of the currently selected tab.
 
         :returns: :class:`Tab` instance.
         """
         return self.tabs[self.selected_index]
--- a/testing/puppeteer/firefox/firefox_puppeteer/ui/browser/toolbars.py
+++ b/testing/puppeteer/firefox/firefox_puppeteer/ui/browser/toolbars.py
@@ -93,17 +93,17 @@ class LocationBar(UIBaseLib):
 
         return self._autocomplete_results
 
     def clear(self):
         """Clears the contents of the url bar (via the DELETE shortcut)."""
         self.focus('shortcut')
         self.urlbar.send_keys(keys.Keys.DELETE)
         Wait(self.marionette).until(
-            lambda _: self.urlbar.get_attribute('value') == '',
+            lambda _: self.urlbar.get_property('value') == '',
             message='Contents of location bar could not be cleared.')
 
     def close_context_menu(self):
         """Closes the Location Bar context menu by a key event."""
         # TODO: This method should be implemented via the menu API.
         self.contextmenu.send_keys(keys.Keys.ESCAPE)
 
     @property
@@ -125,17 +125,17 @@ class LocationBar(UIBaseLib):
         return parent.find_element(By.ANON_ATTRIBUTE, {'anonid': 'input-box-contextmenu'})
 
     @property
     def focused(self):
         """Checks the focus state of the location bar.
 
         :returns: `True` if focused, otherwise `False`
         """
-        return self.urlbar.get_attribute('focused') == 'true'
+        return self.urlbar.get_property('focused')
 
     @property
     def identity_icon(self):
         """ Provides access to the urlbar identity icon.
 
         :returns: Reference to the identity icon element.
         """
         return self.marionette.find_element(By.ID, 'identity-icon')
@@ -293,17 +293,17 @@ class LocationBar(UIBaseLib):
         return self.urlbar.find_element(By.ANON_ATTRIBUTE, {'anonid': 'input'})
 
     @property
     def value(self):
         """Provides access to the currently displayed value of the urlbar.
 
         :returns: The urlbar value.
         """
-        return self.urlbar.get_attribute('value')
+        return self.urlbar.get_property('value')
 
 
 class AutocompleteResults(UIBaseLib):
     """Wraps DOM elements and methods for interacting with autocomplete results."""
 
     def close(self, force=False):
         """Closes the urlbar autocomplete popup.
 
@@ -337,25 +337,25 @@ class AutocompleteResults(UIBaseLib):
                              '"title" or "url", not %s' % match_type)
 
         # Search for nodes of the given type with emphasized text
         emphasized_nodes = result.find_elements(
             By.ANON_ATTRIBUTE,
             {'class': 'ac-emphasize-text ac-emphasize-text-%s' % match_type}
         )
 
-        return [node.get_attribute('textContent') for node in emphasized_nodes]
+        return [node.get_property('textContent') for node in emphasized_nodes]
 
     @property
     def visible_results(self):
         """Supplies the list of visible autocomplete result nodes.
 
         :returns: The list of visible results.
         """
-        match_count = self.element.get_attribute('_matchCount')
+        match_count = self.element.get_property('_matchCount')
 
         return self.marionette.execute_script("""
           let rv = [];
           let node = arguments[0];
           let count = arguments[1];
 
           for (let i = 0; i < count; ++i) {
             rv.push(node.getItemAtIndex(i));
@@ -365,17 +365,17 @@ class AutocompleteResults(UIBaseLib):
         """, script_args=[self.results, match_count])
 
     @property
     def is_open(self):
         """Returns whether this popup is currently open.
 
         :returns: True when the popup is open, otherwise false.
         """
-        return self.element.get_attribute('state') == 'open'
+        return self.element.get_property('state') == 'open'
 
     @property
     def is_complete(self):
         """Returns when this popup is open and autocomplete results are complete.
 
         :returns: True, when autocomplete results have been populated.
         """
         return self.marionette.execute_script("""
@@ -399,34 +399,34 @@ class AutocompleteResults(UIBaseLib):
                                          {'anonid': 'richlistbox'})
 
     @property
     def selected_index(self):
         """Provides the index of the selected item in the autocomplete list.
 
         :returns: The index.
         """
-        return self.results.get_attribute('selectedIndex')
+        return self.results.get_property('selectedIndex')
 
 
 class IdentityPopup(UIBaseLib):
     """Wraps DOM elements and methods for interacting with the identity popup."""
 
     def __init__(self, *args, **kwargs):
         super(IdentityPopup, self).__init__(*args, **kwargs)
 
         self._view = None
 
     @property
     def is_open(self):
         """Returns whether this popup is currently open.
 
         :returns: True when the popup is open, otherwise false.
         """
-        return self.element.get_attribute('state') == 'open'
+        return self.element.get_property('state') == 'open'
 
     def close(self, force=False):
         """Closes the identity popup by hitting the escape key.
 
         :param force: Optional, If `True` force close the popup.
          Defaults to `False`
         """
         if not self.is_open:
@@ -493,17 +493,17 @@ class IdentityPopupMultiView(UIBaseLib):
 class IdentityPopupView(UIBaseLib):
 
     @property
     def selected(self):
         """Checks if the view is selected.
 
         :return: `True` if the view is selected.
         """
-        return self.element.get_attribute('current') == 'true'
+        return self.element.get_attribute('current')
 
 
 class IdentityPopupMainView(IdentityPopupView):
 
     @property
     def selected(self):
         """Checks if the view is selected.