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

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

Issue 2785083002: Use devtools to set user agent in chromedriver (Closed)
Patch Set: Fix 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..72fa647ac1e0644e6ad58b49e6a0f27119babbd4 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,24 @@ 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/empty.html'))
+ old_windows = driver.GetWindowHandles()
+ user_agent_url = self._http_server.GetUrl() + '/userAgent'
+ driver.ExecuteScript(
+ ('document.body.innerHTML = "<a href=\\"%s\\" '
+ 'target=\\"_blank\\">test</a>";') % user_agent_url)
+
+ link = driver.FindElement('tag name', 'a')
+ driver.MouseMoveTo(link)
+ driver.MouseClick()
+ new_window = self.WaitForNewWindow(driver, old_windows)
+ driver.SwitchToWindow(new_window)
+ 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