Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(794)

Side by Side Diff: chrome/test/webdriver/webdriver_remote_tests.py

Issue 6330012: Cookie commands for the webdriver protocol (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: minor fixes Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/test/webdriver/session.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright (c) 2010 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2010 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 try: 6 try:
7 import json 7 import json
8 except ImportError: # < 2.6 8 except ImportError: # < 2.6
9 import simplejson as json 9 import simplejson as json
10 10
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 else: 89 else:
90 WEBDRIVER_PROCESS.kill() 90 WEBDRIVER_PROCESS.kill()
91 WEBDRIVER_PROCESS = None 91 WEBDRIVER_PROCESS = None
92 92
93 """Preforms a string search ignoring case""" 93 """Preforms a string search ignoring case"""
94 def assertFind(self, text, search): 94 def assertFind(self, text, search):
95 text = string.lower(text) 95 text = string.lower(text)
96 search = string.lower(search) 96 search = string.lower(search)
97 self.assertNotEqual(-1, string.find(text, search)) 97 self.assertNotEqual(-1, string.find(text, search))
98 98
99
99 class TestFindElement(RemoteWebDriverTest): 100 class TestFindElement(RemoteWebDriverTest):
100 def testFindByName(self): 101 def testFindByName(self):
101 navigate(SEARCH) 102 self.navigate(SEARCH)
102 # Find the Google search button. 103 # Find the Google search button.
103 q = self.driver.find_element_by_name("q") 104 q = self.driver.find_element_by_name("q")
104 self.assertTrue(isinstance(q, WebElement)) 105 self.assertTrue(isinstance(q, WebElement))
105 # Trying looking for an element not on the page. 106 # Trying looking for an element not on the page.
106 self.assertRaises(NoSuchElementException, 107 self.assertRaises(NoSuchElementException,
107 self.driver.find_elment_by_name, "q2") 108 self.driver.find_elment_by_name, "q2")
108 # Try to find the Google search button using the multiple find method. 109 # Try to find the Google search button using the multiple find method.
109 q = self.driver.find_elements_by_name("q") 110 q = self.driver.find_elements_by_name("q")
110 self.assertTrue(isinstance(q, list)) 111 self.assertTrue(isinstance(q, list))
111 self.assertTrue(len(q), 1) 112 self.assertTrue(len(q), 1)
112 self.assertTrue(isinstance(q[0], WebElement)) 113 self.assertTrue(isinstance(q[0], WebElement))
113 # Try finding something not on page, with multiple find an empty array 114 # Try finding something not on page, with multiple find an empty array
114 # should return and no exception thrown. 115 # should return and no exception thrown.
115 q = self.driver.find_elements_by_name("q2") 116 q = self.driver.find_elements_by_name("q2")
116 assertTrue(q == []) 117 assertTrue(q == [])
117 # Find a hidden element on the page 118 # Find a hidden element on the page
118 q = self.driver.find_element_by_name("oq") 119 q = self.driver.find_element_by_name("oq")
119 self.assertTrue(isinstance(q, WebElement)) 120 self.assertTrue(isinstance(q, WebElement))
120 121
121 def testFindElementById(self): 122 def testFindElementById(self):
122 navigate(SEARCH) 123 self.navigate(SEARCH)
123 # Find the padding for the logo near the search bar. 124 # Find the padding for the logo near the search bar.
124 elem = self.driver.find_element_by_id("logocont") 125 elem = self.driver.find_element_by_id("logocont")
125 self.assertTrue(isinstance(elem, WebElement)) 126 self.assertTrue(isinstance(elem, WebElement))
126 # Look for an ID not there. 127 # Look for an ID not there.
127 self.assertRaises(NoSuchElementException, 128 self.assertRaises(NoSuchElementException,
128 self.driver.find_element_by_id, "logocont") 129 self.driver.find_element_by_id, "logocont")
129 130
130 def testFindElementById0WithTimeout(self): 131 def testFindElementById0WithTimeout(self):
131 self.set_implicit_wait(0) 132 self.set_implicit_wait(0)
132 navigate(SEARCH) 133 self.navigate(SEARCH)
133 # Find the padding for the logo near the search bar. 134 # Find the padding for the logo near the search bar.
134 elem = self.driver.find_element_by_id("logocont") 135 elem = self.driver.find_element_by_id("logocont")
135 self.assertTrue(isinstance(elem, WebElement)) 136 self.assertTrue(isinstance(elem, WebElement))
136 self.set_implicit_wait(5000) 137 self.set_implicit_wait(5000)
137 navigate(SEARCH) 138 self.navigate(SEARCH)
138 # Look for an ID not there. 139 # Look for an ID not there.
139 self.assertRaises(NoSuchElementException, 140 self.assertRaises(NoSuchElementException,
140 self.driver.find_element_by_id, "logocont") 141 self.driver.find_element_by_id, "logocont")
142
143
144 class TestFindElement(RemoteWebDriverTest):
145 def testFindByName(self):
146 self.navigate(SEARCH)
147 # Find the Google search button.
148 q = self.driver.find_element_by_name("q")
149 self.assertTrue(isinstance(q, WebElement))
150 # Trying looking for an element not on the page.
151 self.assertRaises(NoSuchElementException,
152 self.driver.find_elment_by_name, "q2")
153 # Try to find the Google search button using the multiple find method.
154 q = self.driver.find_elements_by_name("q")
155 self.assertTrue(isinstance(q, list))
156 self.assertTrue(len(q), 1)
157 self.assertTrue(isinstance(q[0], WebElement))
158 # Try finding something not on page, with multiple find an empty array
159 # should return and no exception thrown.
160 q = self.driver.find_elements_by_name("q2")
161 assertTrue(q == [])
162 # Find a hidden element on the page
163 q = self.driver.find_element_by_name("oq")
164 self.assertTrue(isinstance(q, WebElement))
165
166 def testFindElementById(self):
167 self.navigate(SEARCH)
168 # Find the padding for the logo near the search bar.
169 elem = self.driver.find_element_by_id("logocont")
170 self.assertTrue(isinstance(elem, WebElement))
171 # Look for an ID not there.
172 self.assertRaises(NoSuchElementException,
173 self.driver.find_element_by_id, "logocont")
141 174
142 175
143 class TestJavaScriptExecution(RemoteWebDriverTest): 176 class TestJavaScriptExecution(RemoteWebDriverTest):
144 """ Test the execute javascript ability of the remote driver""" 177 """ Test the execute javascript ability of the remote driver"""
145 def testNoModification(self): 178 def testNoModification(self):
146 self.driver.get("http://www.google.com") 179 self.driver.get("http://www.google.com")
147 title = self.driver.execute_script("return document.title") 180 title = self.driver.execute_script("return document.title")
148 self.assertEqual(title, self.driver.get_title()) 181 self.assertEqual(title, self.driver.get_title())
149 182
150 def testModification(self): 183 def testModification(self):
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 if options.port: 292 if options.port:
260 WEBDRIVER_PORT = options.port 293 WEBDRIVER_PORT = options.port
261 if options.exe: 294 if options.exe:
262 WEBDRIVER_EXE = options.exe 295 WEBDRIVER_EXE = options.exe
263 if not os.path.exists(WEBDRIVER_EXE): 296 if not os.path.exists(WEBDRIVER_EXE):
264 parser.error('WebDriver server executable not found:\n\t%s\n' 297 parser.error('WebDriver server executable not found:\n\t%s\n'
265 'Please specify a valid path with the --exe flag.' 298 'Please specify a valid path with the --exe flag.'
266 % WEBDRIVER_EXE) 299 % WEBDRIVER_EXE)
267 300
268 unittest.main() 301 unittest.main()
OLDNEW
« no previous file with comments | « chrome/test/webdriver/session.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698