summaryrefslogtreecommitdiffstats
path: root/chrome/test/functional/execute_javascript.py
blob: f999f3a854678a511acab51ed2550e08c61f46ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/python
# Copyright (c) 2010 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import os
import sys
import unittest

import pyauto_functional
from pyauto import PyUITest


class ExecuteJavascriptTest(PyUITest):

  def testExecuteJavascript(self):
    path = os.path.join(self.DataDir(), "frame_dom_access",
                       "frame_dom_access.html")

    self.NavigateToURL(self.GetFileURLForPath(path))

    v = self.ExecuteJavascript("window.domAutomationController.send(" +
                               "document.getElementById('myinput').nodeName)")
    self.assertEqual(v, "INPUT")

  def testGetDOMValue(self):
    path = os.path.join(self.DataDir(), "frame_dom_access",
                       "frame_dom_access.html")

    self.NavigateToURL(self.GetFileURLForPath(path))

    v = self.GetDOMValue("document.getElementById('myinput').nodeName")
    self.assertEqual(v, "INPUT")


if __name__ == '__main__':
  pyauto_functional.Main()