diff options
author | dennisjeffrey@chromium.org <dennisjeffrey@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-26 20:51:22 +0000 |
---|---|---|
committer | dennisjeffrey@chromium.org <dennisjeffrey@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-26 20:51:22 +0000 |
commit | 264af81a2135c2fb71b8fcfc162fc6bfe9e2e0de (patch) | |
tree | 1b45fa1683124ef9ef0ddb42732ad43b7aff5314 | |
parent | 40df242a06b4caced65f9788677248f7f473a415 (diff) | |
download | chromium_src-264af81a2135c2fb71b8fcfc162fc6bfe9e2e0de.zip chromium_src-264af81a2135c2fb71b8fcfc162fc6bfe9e2e0de.tar.gz chromium_src-264af81a2135c2fb71b8fcfc162fc6bfe9e2e0de.tar.bz2 |
Revise 2 pyauto shortcuts tests to account for UI changes.
One test fails because a DOM element cannot be located. This DOM element
now exists inside an iframe. The test has been modified to ensure the
appropriate iframe exists.
The other test fails because a tab name isn't as expected. The problem here
is that there is a redirection in which case the tab name is temporarily
"Loading...", and that's the value the test was seeing. The test now
follows the convention of other pyauto tests in such a situation by waiting
until the tab name changes to be the expected value.
BUG=120041
TEST=Verified the tests used to fail, but now pass with these changes
using --repeat=5 on my local linux machine.
Review URL: https://chromiumcodereview.appspot.com/9854004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@128998 0039d316-1c4b-4281-b951-d872f2087c98
-rwxr-xr-x | chrome/test/functional/shortcuts.py | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/chrome/test/functional/shortcuts.py b/chrome/test/functional/shortcuts.py index bcb5ee8..9a8cc1c 100755 --- a/chrome/test/functional/shortcuts.py +++ b/chrome/test/functional/shortcuts.py @@ -89,15 +89,27 @@ class ShortcutsTest(pyauto.PyUITest): self.NavigateToURL(self.GetFileURLForDataPath('title2.html')) self.ApplyAccelerator(pyauto.IDC_CLEAR_BROWSING_DATA) self.assertEquals(2, self.GetTabCount()) - self.assertTrue(re.search('clearBrowserData', - self.GetActiveTabURL().spec()), 'Clear browsing data url is wrong.') - # Wait until the clear browsing data DOM UI window opens. - self.assertTrue(self.WaitUntil(lambda: - self.ExecuteJavascript( - 'var element = document.getElementById("clearBrowserDataOverlay");' - 'if(element) window.domAutomationController.send(element.nodeName);' - 'else window.domAutomationController.send("")', 1), - expect_retval='DIV'), msg='Could not find the DOM UI window element.') + self.assertTrue( + re.search('clearBrowserData', self.GetActiveTabURL().spec()), + msg='Clear browsing data url is wrong: "%s"' % + self.GetActiveTabURL().spec()) + # Wait until the clear browsing data DOM UI iframe is present. + find_dom_element_js = """ + var frames = document.getElementsByTagName("iframe"); + var sent_result = false; + for (var i = 0; i < frames.length; ++i) + if (frames[i].src == "chrome://settings-frame/clearBrowserData") { + window.domAutomationController.send("true"); + sent_result = true; + } + if (!sent_result) + window.domAutomationController.send("false"); + """ + self.assertTrue( + self.WaitUntil( + lambda: self.ExecuteJavascript(find_dom_element_js, tab_index=1), + expect_retval='true'), + msg='Could not find the DOM UI window element iframe.') def testViewSourceShortcut(self): """Verify view source shortcut.""" @@ -130,8 +142,10 @@ class ShortcutsTest(pyauto.PyUITest): def testHistoryShortcut(self): """Verify history shortcut opens history page.""" self.RunCommand(pyauto.IDC_SHOW_HISTORY) - self.assertEqual('History', self.GetActiveTabTitle(), - msg='History page was not opened.') + self.assertTrue( + self.WaitUntil(lambda: 'History' == self.GetActiveTabTitle()), + msg='History page was not opened; tab title is "%s"' % + self.GetActiveTabTitle()) def testDownloadsShortcut(self): """Verify downloads shortcut opens downloads page.""" |