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

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: dsdsdsdjsdsj 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
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 testCookies(RemoteWebDriverTest):
John Grabowski 2011/02/14 21:59:06 like all this
Joe 2011/02/15 02:30:48 FYI It''s still here I just moved it to a new sect
145 def testAddCookie(self):
146 self.navigate(SEARCH)
147 cookie_dict = {}
148 cookie_dict["name"]= "chromedriver_cookie_test";
149 cookie_dict["value"] = "this is a test";
150 self.driver.add_cookie(cookie_dict)
151 cookie_dict = None
152 cookie_dict = self.driver.get_cookie("chromedriver_cookie_test")
153 self.assertNotEqual(cookie_dict, None)
154 self.assertEqual(cookie_dict["value"], "this is a test";);
155
156 def testDeleteCookie(self):
157 testAddCookie();
158 self.driver.delete_cookie("chromedriver_cookie_test")
159 cookie_dict = self.driver.get_cookie("chromedriver_cookie_test")
160 self.assertEqual(cookie_dict, None)
161
162 class TestFindElement(RemoteWebDriverTest):
163 def testFindByName(self):
164 self.navigate(SEARCH)
165 # Find the Google search button.
166 q = self.driver.find_element_by_name("q")
167 self.assertTrue(isinstance(q, WebElement))
168 # Trying looking for an element not on the page.
169 self.assertRaises(NoSuchElementException,
170 self.driver.find_elment_by_name, "q2")
171 # Try to find the Google search button using the multiple find method.
172 q = self.driver.find_elements_by_name("q")
173 self.assertTrue(isinstance(q, list))
174 self.assertTrue(len(q), 1)
175 self.assertTrue(isinstance(q[0], WebElement))
176 # Try finding something not on page, with multiple find an empty array
177 # should return and no exception thrown.
178 q = self.driver.find_elements_by_name("q2")
179 assertTrue(q == [])
180 # Find a hidden element on the page
181 q = self.driver.find_element_by_name("oq")
182 self.assertTrue(isinstance(q, WebElement))
183
184 def testFindElementById(self):
185 self.navigate(SEARCH)
186 # Find the padding for the logo near the search bar.
187 elem = self.driver.find_element_by_id("logocont")
188 self.assertTrue(isinstance(elem, WebElement))
189 # Look for an ID not there.
190 self.assertRaises(NoSuchElementException,
191 self.driver.find_element_by_id, "logocont")
141 192
142 193
143 class TestJavaScriptExecution(RemoteWebDriverTest): 194 class TestJavaScriptExecution(RemoteWebDriverTest):
144 """ Test the execute javascript ability of the remote driver""" 195 """ Test the execute javascript ability of the remote driver"""
145 def testNoModification(self): 196 def testNoModification(self):
146 self.driver.get("http://www.google.com") 197 self.driver.get("http://www.google.com")
147 title = self.driver.execute_script("return document.title") 198 title = self.driver.execute_script("return document.title")
148 self.assertEqual(title, self.driver.get_title()) 199 self.assertEqual(title, self.driver.get_title())
149 200
150 def testModification(self): 201 def testModification(self):
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 if options.port: 310 if options.port:
260 WEBDRIVER_PORT = options.port 311 WEBDRIVER_PORT = options.port
261 if options.exe: 312 if options.exe:
262 WEBDRIVER_EXE = options.exe 313 WEBDRIVER_EXE = options.exe
263 if not os.path.exists(WEBDRIVER_EXE): 314 if not os.path.exists(WEBDRIVER_EXE):
264 parser.error('WebDriver server executable not found:\n\t%s\n' 315 parser.error('WebDriver server executable not found:\n\t%s\n'
265 'Please specify a valid path with the --exe flag.' 316 'Please specify a valid path with the --exe flag.'
266 % WEBDRIVER_EXE) 317 % WEBDRIVER_EXE)
267 318
268 unittest.main() 319 unittest.main()
OLDNEW
« chrome/test/webdriver/cookie.h ('K') | « chrome/test/webdriver/session.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698