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

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: update 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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 class TestFindElement(RemoteWebDriverTest): 99 class TestFindElement(RemoteWebDriverTest):
100 def testFindByName(self): 100 def testFindByName(self):
101 navigate(SEARCH) 101 self.navigate(SEARCH)
102 # Find the Google search button. 102 # Find the Google search button.
103 q = self.driver.find_element_by_name("q") 103 q = self.driver.find_element_by_name("q")
104 self.assertTrue(isinstance(q, WebElement)) 104 self.assertTrue(isinstance(q, WebElement))
105 # Trying looking for an element not on the page. 105 # Trying looking for an element not on the page.
106 self.assertRaises(NoSuchElementException, 106 self.assertRaises(NoSuchElementException,
107 self.driver.find_elment_by_name, "q2") 107 self.driver.find_elment_by_name, "q2")
108 # Try to find the Google search button using the multiple find method. 108 # Try to find the Google search button using the multiple find method.
109 q = self.driver.find_elements_by_name("q") 109 q = self.driver.find_elements_by_name("q")
110 self.assertTrue(isinstance(q, list)) 110 self.assertTrue(isinstance(q, list))
111 self.assertTrue(len(q), 1) 111 self.assertTrue(len(q), 1)
112 self.assertTrue(isinstance(q[0], WebElement)) 112 self.assertTrue(isinstance(q[0], WebElement))
113 # Try finding something not on page, with multiple find an empty array 113 # Try finding something not on page, with multiple find an empty array
114 # should return and no exception thrown. 114 # should return and no exception thrown.
115 q = self.driver.find_elements_by_name("q2") 115 q = self.driver.find_elements_by_name("q2")
116 assertTrue(q == []) 116 assertTrue(q == [])
117 # Find a hidden element on the page 117 # Find a hidden element on the page
118 q = self.driver.find_element_by_name("oq") 118 q = self.driver.find_element_by_name("oq")
119 self.assertTrue(isinstance(q, WebElement)) 119 self.assertTrue(isinstance(q, WebElement))
120 120
121 def testFindElementById(self): 121 def testFindElementById(self):
122 navigate(SEARCH) 122 self.navigate(SEARCH)
123 # Find the padding for the logo near the search bar. 123 # Find the padding for the logo near the search bar.
124 elem = self.driver.find_element_by_id("logocont") 124 elem = self.driver.find_element_by_id("logocont")
125 self.assertTrue(isinstance(elem, WebElement)) 125 self.assertTrue(isinstance(elem, WebElement))
126 # Look for an ID not there. 126 # Look for an ID not there.
127 self.assertRaises(NoSuchElementException, 127 self.assertRaises(NoSuchElementException,
128 self.driver.find_element_by_id, "logocont") 128 self.driver.find_element_by_id, "logocont")
129 129
130 def testFindElementById0WithTimeout(self): 130 def testFindElementById0WithTimeout(self):
131 self.set_implicit_wait(0) 131 self.set_implicit_wait(0)
132 navigate(SEARCH) 132 self.navigate(SEARCH)
133 # Find the padding for the logo near the search bar. 133 # Find the padding for the logo near the search bar.
134 elem = self.driver.find_element_by_id("logocont") 134 elem = self.driver.find_element_by_id("logocont")
135 self.assertTrue(isinstance(elem, WebElement)) 135 self.assertTrue(isinstance(elem, WebElement))
136 self.set_implicit_wait(5000) 136 self.set_implicit_wait(5000)
137 navigate(SEARCH) 137 self.navigate(SEARCH)
138 # Look for an ID not there. 138 # Look for an ID not there.
139 self.assertRaises(NoSuchElementException, 139 self.assertRaises(NoSuchElementException,
140 self.driver.find_element_by_id, "logocont") 140 self.driver.find_element_by_id, "logocont")
141
142
John Grabowski 2011/02/04 02:40:23 excellent
143 class testCookies(RemoteWebDriverTest):
144 def testAddCookie(self):
145 self.navigate(SEARCH)
146 cookie_dict = {}
147 cookie_dict["name"]= "chromedriver_cookie_test";
148 cookie_dict["value"] = "this is a test";
149 self.driver.add_cookie(cookie_dict)
150 cookie_dict = None
151 cookie_dict = self.driver.get_cookie("chromedriver_cookie_test")
152 self.assertNotEqual(cookie_dict, None)
153 self.assertEqual(cookie_dict["value"], "this is a test";);
154
155 def testDeleteCookie(self):
156 testAddCookie();
157 self.driver.delete_cookie("chromedriver_cookie_test")
158 cookie_dict = self.driver.get_cookie("chromedriver_cookie_test")
159 self.assertEqual(cookie_dict, None)
160
161 class TestFindElement(RemoteWebDriverTest):
162 def testFindByName(self):
163 self.navigate(SEARCH)
164 # Find the Google search button.
165 q = self.driver.find_element_by_name("q")
166 self.assertTrue(isinstance(q, WebElement))
167 # Trying looking for an element not on the page.
168 self.assertRaises(NoSuchElementException,
169 self.driver.find_elment_by_name, "q2")
170 # Try to find the Google search button using the multiple find method.
171 q = self.driver.find_elements_by_name("q")
172 self.assertTrue(isinstance(q, list))
173 self.assertTrue(len(q), 1)
174 self.assertTrue(isinstance(q[0], WebElement))
175 # Try finding something not on page, with multiple find an empty array
176 # should return and no exception thrown.
177 q = self.driver.find_elements_by_name("q2")
178 assertTrue(q == [])
179 # Find a hidden element on the page
180 q = self.driver.find_element_by_name("oq")
181 self.assertTrue(isinstance(q, WebElement))
182
183 def testFindElementById(self):
184 self.navigate(SEARCH)
185 # Find the padding for the logo near the search bar.
186 elem = self.driver.find_element_by_id("logocont")
187 self.assertTrue(isinstance(elem, WebElement))
188 # Look for an ID not there.
189 self.assertRaises(NoSuchElementException,
190 self.driver.find_element_by_id, "logocont")
141 191
142 192
143 class TestJavaScriptExecution(RemoteWebDriverTest): 193 class TestJavaScriptExecution(RemoteWebDriverTest):
144 """ Test the execute javascript ability of the remote driver""" 194 """ Test the execute javascript ability of the remote driver"""
145 def testNoModification(self): 195 def testNoModification(self):
146 self.driver.get("http://www.google.com") 196 self.driver.get("http://www.google.com")
147 title = self.driver.execute_script("return document.title") 197 title = self.driver.execute_script("return document.title")
148 self.assertEqual(title, self.driver.get_title()) 198 self.assertEqual(title, self.driver.get_title())
149 199
150 def testModification(self): 200 def testModification(self):
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 if options.port: 309 if options.port:
260 WEBDRIVER_PORT = options.port 310 WEBDRIVER_PORT = options.port
261 if options.exe: 311 if options.exe:
262 WEBDRIVER_EXE = options.exe 312 WEBDRIVER_EXE = options.exe
263 if not os.path.exists(WEBDRIVER_EXE): 313 if not os.path.exists(WEBDRIVER_EXE):
264 parser.error('WebDriver server executable not found:\n\t%s\n' 314 parser.error('WebDriver server executable not found:\n\t%s\n'
265 'Please specify a valid path with the --exe flag.' 315 'Please specify a valid path with the --exe flag.'
266 % WEBDRIVER_EXE) 316 % WEBDRIVER_EXE)
267 317
268 unittest.main() 318 unittest.main()
OLDNEW
« chrome/test/webdriver/cookie.cc ('K') | « chrome/test/webdriver/server.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698