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

Unified Diff: chrome/test/chromedriver/test/run_py_tests.py

Issue 2785083002: Use devtools to set user agent in chromedriver (Closed)
Patch Set: Add new tab test Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/chromedriver/chrome_launcher.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/chromedriver/test/run_py_tests.py
diff --git a/chrome/test/chromedriver/test/run_py_tests.py b/chrome/test/chromedriver/test/run_py_tests.py
index 2c5e728952ef44f8938b54e24d74f51f13a94c72..c64d862debed30e4ef5c4a167a2191c15796cfab 100755
--- a/chrome/test/chromedriver/test/run_py_tests.py
+++ b/chrome/test/chromedriver/test/run_py_tests.py
@@ -1836,7 +1836,7 @@ class ChromeLogPathCapabilityTest(ChromeDriverBaseTest):
self.assertTrue(self.LOG_MESSAGE in open(tmp_log_path.name).read())
-class MobileEmulationCapabilityTest(ChromeDriverBaseTest):
+class MobileEmulationCapabilityTest(ChromeDriverBaseTestWithWebServer):
"""Tests that ChromeDriver processes chromeOptions.mobileEmulation.
Makes sure the device metrics are overridden in DevTools and user agent is
@@ -1905,6 +1905,20 @@ class MobileEmulationCapabilityTest(ChromeDriverBaseTest):
body_tag = driver.FindElement('tag name', 'body')
self.assertEqual("Agent Smith", body_tag.GetText())
+ def testUserAgentNewTab(self):
+ driver = self.CreateDriver(
+ mobile_emulation = {'userAgent': 'Agent Smith'})
+ driver.Load(self.GetHttpUrlForFile('/chromedriver/newtab.html'))
+ old_windows = driver.GetWindowHandles()
+ link = driver.FindElements('tag name', 'a')[0]
+ driver.MouseMoveTo(link)
+ driver.MouseClick()
stgao 2017/04/05 04:17:08 What's the user-agent if the new tab itself direct
irisu 2017/04/05 06:44:33 Sorry for that misunderstanding. Modified the test
Sami 2017/04/05 13:52:04 Right, looks like we need to support a default use
+ new_window = self.WaitForNewWindow(driver, old_windows)
+ driver.SwitchToWindow(new_window)
+ driver.Load(self._http_server.GetUrl() + '/userAgent')
stgao 2017/04/05 04:17:08 Before this load, we already instruct the new tab
+ body_tag = driver.FindElement('tag name', 'body')
+ self.assertEqual("Agent Smith", body_tag.GetText())
+
def testDeviceName(self):
driver = self.CreateDriver(
mobile_emulation = {'deviceName': 'Google Nexus 5'})
« no previous file with comments | « chrome/test/chromedriver/chrome_launcher.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698