OLD | NEW |
---|---|
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """WebsiteTest testing class.""" | 5 """WebsiteTest testing class.""" |
6 | 6 |
7 import logging | 7 import logging |
8 import sys | |
9 import time | 8 import time |
10 | 9 |
11 sys.path.insert(0, '../../../../third_party/webdriver/pylib/') | |
engedy
2015/03/26 16:18:56
Could you please allude in the CL description to w
vabr (Chromium)
2015/03/26 18:01:50
Done.
| |
12 | |
13 from selenium.webdriver.common.action_chains import ActionChains | 10 from selenium.webdriver.common.action_chains import ActionChains |
14 from selenium.webdriver.common.keys import Keys | 11 from selenium.webdriver.common.keys import Keys |
15 | 12 |
16 import environment | 13 import environment |
17 | 14 |
18 | 15 |
19 def _IsOneSubstringOfAnother(s1, s2): | 16 def _IsOneSubstringOfAnother(s1, s2): |
20 """Checks if one of the string arguements is substring of the other. | 17 """Checks if one of the string arguements is substring of the other. |
21 | 18 |
22 Args: | 19 Args: |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
128 | 125 |
129 Args: | 126 Args: |
130 selector: The element CSS selector. | 127 selector: The element CSS selector. |
131 """ | 128 """ |
132 logging.info("action: Hover %s" % selector) | 129 logging.info("action: Hover %s" % selector) |
133 self.WaitUntilDisplayed(selector) | 130 self.WaitUntilDisplayed(selector) |
134 element = self.driver.find_element_by_css_selector(selector) | 131 element = self.driver.find_element_by_css_selector(selector) |
135 hover = ActionChains(self.driver).move_to_element(element) | 132 hover = ActionChains(self.driver).move_to_element(element) |
136 hover.perform() | 133 hover.perform() |
137 | 134 |
138 def SendEnterTo(self, selector): | |
139 """Sends an enter key to an element. | |
140 | |
141 Args: | |
142 selector: The element CSS selector. | |
143 """ | |
144 logging.info("action: SendEnterTo %s" % selector) | |
145 body = self.driver.find_element_by_tag_name("body") | |
146 body.send_keys(Keys.ENTER) | |
147 | |
148 # Waiting/Displaying actions. | 135 # Waiting/Displaying actions. |
149 | 136 |
150 def IsDisplayed(self, selector): | 137 def IsDisplayed(self, selector): |
151 """Returns False if an element doesn't exist in the DOM or is 100% | 138 """Returns False if an element doesn't exist in the DOM or is 100% |
152 transparent. Otherwise, returns True even if it's covered by another | 139 transparent. Otherwise, returns True even if it's covered by another |
153 element or it's out viewing area. | 140 element or it's out viewing area. |
154 | 141 |
155 Args: | 142 Args: |
156 selector: The element CSS selector. | 143 selector: The element CSS selector. |
157 """ | 144 """ |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
405 self.LoginWhenNotAutofilled() | 392 self.LoginWhenNotAutofilled() |
406 self.Wait(2) | 393 self.Wait(2) |
407 self.environment.SwitchToInternals() | 394 self.environment.SwitchToInternals() |
408 self.environment.CheckForNewMessage( | 395 self.environment.CheckForNewMessage( |
409 environment.MESSAGE_ASK, | 396 environment.MESSAGE_ASK, |
410 True, | 397 True, |
411 "Error: password manager hasn't detected a successful login for the " | 398 "Error: password manager hasn't detected a successful login for the " |
412 "following website : %s \n" % self.name) | 399 "following website : %s \n" % self.name) |
413 finally: | 400 finally: |
414 self.environment.SwitchFromInternals() | 401 self.environment.SwitchFromInternals() |
OLD | NEW |