From 6b428e815061e5bff682adbcf24c0e5356d67fa1 Mon Sep 17 00:00:00 2001 From: David Burns Date: Wed, 26 Aug 2015 19:52:09 +0100 Subject: [PATCH] Bug 1198542: Update Marionette element IDs to be valid UUID. r=ato This allows WebDriver compatibility to create valid URI. --HG-- extra : commitid : 7JjQgqwKr8P extra : rebase_source : 30e59c18b69ab404608c6b44f1dc11742b95ac78 --- .../client/marionette/tests/unit/test_findelement.py | 10 ++++++++++ testing/marionette/elements.js | 3 ++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/testing/marionette/client/marionette/tests/unit/test_findelement.py b/testing/marionette/client/marionette/tests/unit/test_findelement.py index 1057e2185f13..5d4ed9848ac5 100644 --- a/testing/marionette/client/marionette/tests/unit/test_findelement.py +++ b/testing/marionette/client/marionette/tests/unit/test_findelement.py @@ -159,3 +159,13 @@ class TestElements(MarionetteTestCase): test_html = self.marionette.absolute_url("test.html") self.marionette.navigate(test_html) self.assertRaises(InvalidSelectorException, self.marionette.find_element, "Brie Search Type", "doesn't matter") + + def test_element_id_is_valid_uuid(self): + import re + test_html = self.marionette.absolute_url("test.html") + self.marionette.navigate(test_html) + el = self.marionette.find_element(By.TAG_NAME, "body") + uuid_regex = re.compile('^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$') + self.assertIsNotNone(re.search(uuid_regex, el.id), + 'UUID for the WebElement is not valid. ID is {}'\ + .format(el.id)) diff --git a/testing/marionette/elements.js b/testing/marionette/elements.js index 1ff6b7b34e5c..35b7ece63573 100644 --- a/testing/marionette/elements.js +++ b/testing/marionette/elements.js @@ -233,7 +233,8 @@ ElementManager.prototype = { delete this.seenItems[i]; } } - let id = uuidGen.generateUUID().toString(); + let uuid = uuidGen.generateUUID().toString(); + let id = uuid.substring(1, uuid.length - 1); this.seenItems[id] = Components.utils.getWeakReference(element); return id; },