Index: chrome/test/functional/perf_endure.py |
diff --git a/chrome/test/functional/perf_endure.py b/chrome/test/functional/perf_endure.py |
index c0af9d072b66b7bc00a9d40b9d0dfd76df3537f1..2c3f1d125b4a07e2b23a3d88baa9f0b50595b461 100755 |
--- a/chrome/test/functional/perf_endure.py |
+++ b/chrome/test/functional/perf_endure.py |
@@ -598,11 +598,13 @@ class ChromeEndureGmailTest(ChromeEndureBaseTest): |
# Log into a test Google account and open up Gmail. |
self._LoginToGoogleAccount(account_key='test_google_account_gmail') |
- self.NavigateToURL('http://www.gmail.com') |
- loaded_tab_title = self.GetActiveTabTitle() |
- self.assertTrue(self._TAB_TITLE_SUBSTRING in loaded_tab_title, |
- msg='Loaded tab title does not contain "%s": "%s"' % |
- (self._TAB_TITLE_SUBSTRING, loaded_tab_title)) |
+ self.NavigateToURL(self._GetConfig().get('gmail_url')) |
+ self.assertTrue( |
+ self.WaitUntil(lambda: self._TAB_TITLE_SUBSTRING in |
+ self.GetActiveTabTitle(), |
+ timeout=60, expect_retval=True, retry_sleep=1), |
Nirnimesh
2012/08/21 00:54:43
why are you overriding the timeout?
|
+ msg='Timed out waiting for Gmail to load. Tab title is: %s' % |
+ self.GetActiveTabTitle()) |
self._driver = self.NewWebDriver() |
# Any call to wait.until() will raise an exception if the timeout is hit. |
@@ -619,6 +621,15 @@ class ChromeEndureGmailTest(ChromeEndureBaseTest): |
self.WaitForDomNode('//a[starts-with(@title, "Inbox")]', |
frame_xpath=self._FRAME_XPATH) |
+ # Test whether latency dom element is available. |
+ try: |
+ self._GetLatencyDomElement(5000) |
+ self._has_latency = True |
+ except pyauto_errors.JSONInterfaceError: |
+ logging.info('Skip recording latency as latency ' + |
+ 'dom element is not available.') |
+ self._has_latency = False |
+ |
def _SwitchToCanvasFrame(self, driver): |
"""Switch the WebDriver to Gmail's 'canvas_frame', if it's available. |
@@ -635,11 +646,20 @@ class ChromeEndureGmailTest(ChromeEndureBaseTest): |
except selenium.common.exceptions.NoSuchFrameException: |
return False |
- def _GetLatencyDomElement(self): |
- """Returns a reference to the latency info element in the Gmail DOM.""" |
+ def _GetLatencyDomElement(self, timeout=-1): |
+ """Returns a reference to the latency info element in the Gmail DOM. |
+ |
+ Args: |
+ timeout: The maximum amount of time (in milliseconds) to wait for |
+ the latency dom element to appear, defaults to the |
+ default automation timeout. |
+ Returns: |
+ A latency dom element. |
+ """ |
latency_xpath = ( |
'//span[starts-with(text(), "Why was the last action slow?")]') |
- self.WaitForDomNode(latency_xpath, frame_xpath=self._FRAME_XPATH) |
+ self.WaitForDomNode(latency_xpath, timeout=timeout, |
+ frame_xpath=self._FRAME_XPATH) |
return self._GetElement(self._driver.find_element_by_xpath, latency_xpath) |
def _WaitUntilDomElementRemoved(self, dom_element): |
@@ -672,6 +692,9 @@ class ChromeEndureGmailTest(ChromeEndureBaseTest): |
action_description: A string description of what action is being |
performed. Should not contain spaces. For example, 'Compose'. |
""" |
+ if not self._has_latency: |
+ element.click() |
+ return |
latency_dom_element = self._GetLatencyDomElement() |
element.click() |
# Wait for the old latency value to be removed, before getting the new one. |
@@ -936,7 +959,7 @@ class ChromeEndureDocsTest(ChromeEndureBaseTest): |
# Log into a test Google account and open up Google Docs. |
self._LoginToGoogleAccount() |
- self.NavigateToURL('http://docs.google.com') |
+ self.NavigateToURL(self._GetConfig().get('docs_url')) |
self.assertTrue( |
self.WaitUntil(lambda: self._TAB_TITLE_SUBSTRING in |
self.GetActiveTabTitle(), |
@@ -1008,7 +1031,7 @@ class ChromeEndurePlusTest(ChromeEndureBaseTest): |
# Log into a test Google account and open up Google Plus. |
self._LoginToGoogleAccount() |
- self.NavigateToURL('http://plus.google.com') |
+ self.NavigateToURL(self._GetConfig().get('plus_url')) |
loaded_tab_title = self.GetActiveTabTitle() |
self.assertTrue(self._TAB_TITLE_SUBSTRING in loaded_tab_title, |
msg='Loaded tab title does not contain "%s": "%s"' % |