зеркало из https://github.com/mozilla/gecko-dev.git
Bug 742947 - tests for functionality provided by Selenium atoms, r=jgriffin
This commit is contained in:
Родитель
48ad21095b
Коммит
27db1f9696
|
@ -70,7 +70,7 @@ class HTMLElement(object):
|
|||
return self.marionette.find_elements(method, target, self.id)
|
||||
|
||||
def get_attribute(self, attribute):
|
||||
return self.marionette._send_message('getElementAttribute', 'value', element=self.id, name=attribute)
|
||||
return self.marionette._send_message('getAttributeValue', 'value', element=self.id, name=attribute)
|
||||
|
||||
def click(self):
|
||||
return self.marionette._send_message('clickElement', 'ok', element=self.id)
|
||||
|
|
|
@ -44,3 +44,29 @@ class TestClick(MarionetteTestCase):
|
|||
link.click()
|
||||
self.assertEqual("Clicked", self.marionette.execute_script("return document.getElementById('mozLink').innerHTML;"))
|
||||
|
||||
class TestClickChrome(MarionetteTestCase):
|
||||
def setUp(self):
|
||||
MarionetteTestCase.setUp(self)
|
||||
self.marionette.set_context("chrome")
|
||||
self.win = self.marionette.get_window()
|
||||
#need to get the file:// path for xul
|
||||
unit = os.path.abspath(os.path.join(os.path.realpath(__file__), os.path.pardir))
|
||||
tests = os.path.abspath(os.path.join(unit, os.path.pardir))
|
||||
mpath = os.path.abspath(os.path.join(tests, os.path.pardir))
|
||||
xul = "file://" + os.path.join(mpath, "www", "test.xul")
|
||||
self.marionette.execute_script("window.open('" + xul +"', '_blank', 'chrome,centerscreen');")
|
||||
|
||||
def tearDown(self):
|
||||
self.marionette.execute_script("window.close();")
|
||||
self.marionette.switch_to_window(self.win)
|
||||
MarionetteTestCase.tearDown(self)
|
||||
|
||||
def test_click(self):
|
||||
wins = self.marionette.get_windows()
|
||||
wins.remove(self.win)
|
||||
newWin = wins.pop()
|
||||
self.marionette.switch_to_window(newWin)
|
||||
box = self.marionette.find_element("id", "testBox")
|
||||
self.assertFalse(self.marionette.execute_script("return arguments[0].checked;", [box]))
|
||||
box.click()
|
||||
self.assertTrue(self.marionette.execute_script("return arguments[0].checked;", [box]))
|
||||
|
|
|
@ -0,0 +1,86 @@
|
|||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/ #
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is Marionette Client.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Mozilla Foundation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 2011
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
import os
|
||||
from marionette_test import MarionetteTestCase
|
||||
|
||||
class TestState(MarionetteTestCase):
|
||||
def test_isEnabled(self):
|
||||
test_html = self.marionette.absolute_url("test.html")
|
||||
self.marionette.navigate(test_html)
|
||||
l = self.marionette.find_element("name", "myCheckBox")
|
||||
self.assertTrue(l.enabled())
|
||||
self.marionette.execute_script("arguments[0].disabled = true;", [l])
|
||||
self.assertFalse(l.enabled())
|
||||
|
||||
def test_isDisplayed(self):
|
||||
test_html = self.marionette.absolute_url("test.html")
|
||||
self.marionette.navigate(test_html)
|
||||
l = self.marionette.find_element("name", "myCheckBox")
|
||||
self.assertTrue(l.displayed())
|
||||
self.marionette.execute_script("arguments[0].hidden = true;", [l])
|
||||
self.assertFalse(l.displayed())
|
||||
|
||||
class TestStateChrome(MarionetteTestCase):
|
||||
def setUp(self):
|
||||
MarionetteTestCase.setUp(self)
|
||||
self.marionette.set_context("chrome")
|
||||
self.win = self.marionette.get_window()
|
||||
#need to get the file:// path for xul
|
||||
unit = os.path.abspath(os.path.join(os.path.realpath(__file__), os.path.pardir))
|
||||
tests = os.path.abspath(os.path.join(unit, os.path.pardir))
|
||||
mpath = os.path.abspath(os.path.join(tests, os.path.pardir))
|
||||
xul = "file://" + os.path.join(mpath, "www", "test.xul")
|
||||
self.marionette.execute_script("window.open('" + xul +"', '_blank', 'chrome,centerscreen');")
|
||||
|
||||
def tearDown(self):
|
||||
self.marionette.execute_script("window.close();")
|
||||
self.marionette.switch_to_window(self.win)
|
||||
MarionetteTestCase.tearDown(self)
|
||||
|
||||
def test_isEnabled(self):
|
||||
l = self.marionette.find_element("id", "textInput")
|
||||
self.assertTrue(l.enabled())
|
||||
self.marionette.execute_script("arguments[0].disabled = true;", [l])
|
||||
self.assertFalse(l.enabled())
|
||||
self.marionette.execute_script("arguments[0].disabled = false;", [l])
|
||||
|
||||
def test_isDisplayed(self):
|
||||
l = self.marionette.find_element("id", "textInput")
|
||||
self.assertTrue(l.displayed())
|
||||
self.marionette.execute_script("arguments[0].hidden = true;", [l])
|
||||
self.assertFalse(l.displayed())
|
||||
self.marionette.execute_script("arguments[0].hidden = false;", [l])
|
||||
|
|
@ -45,7 +45,24 @@ class TestElements(MarionetteTestCase):
|
|||
el = self.marionette.execute_script("return window.document.getElementById('mozLink');")
|
||||
found_el = self.marionette.find_element("id", "mozLink")
|
||||
self.assertEqual(HTMLElement, type(found_el))
|
||||
self.assertTrue(el.id, found_el.id)
|
||||
self.assertEqual(el.id, found_el.id)
|
||||
|
||||
def test_child_element(self):
|
||||
test_html = self.marionette.absolute_url("test.html")
|
||||
self.marionette.navigate(test_html)
|
||||
el = self.marionette.find_element("id", "divLink")
|
||||
div = self.marionette.find_element("id", "testDiv")
|
||||
found_el = div.find_element("tag name", "a")
|
||||
self.assertEqual(HTMLElement, type(found_el))
|
||||
self.assertEqual(el.id, found_el.id)
|
||||
|
||||
def test_child_elements(self):
|
||||
test_html = self.marionette.absolute_url("test.html")
|
||||
self.marionette.navigate(test_html)
|
||||
el = self.marionette.find_element("id", "divLink2")
|
||||
div = self.marionette.find_element("id", "testDiv")
|
||||
found_els = div.find_elements("tag name", "a")
|
||||
self.assertTrue(el.id in [found_el.id for found_el in found_els])
|
||||
|
||||
def test_tag_name(self):
|
||||
test_html = self.marionette.absolute_url("test.html")
|
||||
|
@ -53,7 +70,7 @@ class TestElements(MarionetteTestCase):
|
|||
el = self.marionette.execute_script("return window.document.getElementsByTagName('body')[0];")
|
||||
found_el = self.marionette.find_element("tag name", "body")
|
||||
self.assertEqual(HTMLElement, type(found_el))
|
||||
self.assertTrue(el.id, found_el.id)
|
||||
self.assertEqual(el.id, found_el.id)
|
||||
|
||||
def test_class_name(self):
|
||||
test_html = self.marionette.absolute_url("test.html")
|
||||
|
@ -61,7 +78,7 @@ class TestElements(MarionetteTestCase):
|
|||
el = self.marionette.execute_script("return window.document.getElementsByClassName('linkClass')[0];")
|
||||
found_el = self.marionette.find_element("class name", "linkClass")
|
||||
self.assertEqual(HTMLElement, type(found_el));
|
||||
self.assertTrue(el.id, found_el.id)
|
||||
self.assertEqual(el.id, found_el.id)
|
||||
|
||||
def test_name(self):
|
||||
test_html = self.marionette.absolute_url("test.html")
|
||||
|
@ -69,7 +86,7 @@ class TestElements(MarionetteTestCase):
|
|||
el = self.marionette.execute_script("return window.document.getElementsByName('myInput')[0];")
|
||||
found_el = self.marionette.find_element("name", "myInput")
|
||||
self.assertEqual(HTMLElement, type(found_el))
|
||||
self.assertTrue(el.id, found_el.id)
|
||||
self.assertEqual(el.id, found_el.id)
|
||||
|
||||
def test_selector(self):
|
||||
test_html = self.marionette.absolute_url("test.html")
|
||||
|
@ -77,7 +94,7 @@ class TestElements(MarionetteTestCase):
|
|||
el = self.marionette.execute_script("return window.document.getElementById('testh1');")
|
||||
found_el = self.marionette.find_element("css selector", "h1")
|
||||
self.assertEqual(HTMLElement, type(found_el))
|
||||
self.assertTrue(el.id, found_el.id)
|
||||
self.assertEqual(el.id, found_el.id)
|
||||
|
||||
def test_link_text(self):
|
||||
test_html = self.marionette.absolute_url("test.html")
|
||||
|
@ -85,7 +102,7 @@ class TestElements(MarionetteTestCase):
|
|||
el = self.marionette.execute_script("return window.document.getElementById('mozLink');")
|
||||
found_el = self.marionette.find_element("link text", "Click me!")
|
||||
self.assertEqual(HTMLElement, type(found_el))
|
||||
self.assertTrue(el.id, found_el.id)
|
||||
self.assertEqual(el.id, found_el.id)
|
||||
|
||||
def test_partial_link_text(self):
|
||||
test_html = self.marionette.absolute_url("test.html")
|
||||
|
@ -93,7 +110,7 @@ class TestElements(MarionetteTestCase):
|
|||
el = self.marionette.execute_script("return window.document.getElementById('mozLink');")
|
||||
found_el = self.marionette.find_element("partial link text", "Click m")
|
||||
self.assertEqual(HTMLElement, type(found_el))
|
||||
self.assertTrue(el.id, found_el.id)
|
||||
self.assertEqual(el.id, found_el.id)
|
||||
|
||||
def test_xpath(self):
|
||||
test_html = self.marionette.absolute_url("test.html")
|
||||
|
@ -101,7 +118,7 @@ class TestElements(MarionetteTestCase):
|
|||
el = self.marionette.execute_script("return window.document.getElementById('mozLink');")
|
||||
found_el = self.marionette.find_element("xpath", "id('mozLink')")
|
||||
self.assertEqual(HTMLElement, type(found_el))
|
||||
self.assertTrue(el.id, found_el.id)
|
||||
self.assertEqual(el.id, found_el.id)
|
||||
|
||||
def test_not_found(self):
|
||||
test_html = self.marionette.absolute_url("test.html")
|
||||
|
@ -120,30 +137,55 @@ class TestElementsChrome(MarionetteTestCase):
|
|||
def setUp(self):
|
||||
MarionetteTestCase.setUp(self)
|
||||
self.marionette.set_context("chrome")
|
||||
self.win = self.marionette.get_window()
|
||||
#need to get the file:// path for xul
|
||||
unit = os.path.abspath(os.path.join(os.path.realpath(__file__), os.path.pardir))
|
||||
tests = os.path.abspath(os.path.join(unit, os.path.pardir))
|
||||
mpath = os.path.abspath(os.path.join(tests, os.path.pardir))
|
||||
xul = "file://" + os.path.join(mpath, "www", "test.xul")
|
||||
self.marionette.execute_script("window.open('" + xul +"', '_blank', 'chrome,centerscreen');")
|
||||
|
||||
def tearDown(self):
|
||||
self.marionette.execute_script("window.close();")
|
||||
self.marionette.switch_to_window(self.win)
|
||||
MarionetteTestCase.tearDown(self)
|
||||
|
||||
def test_id(self):
|
||||
el = self.marionette.execute_script("return window.document.getElementById('main-window');")
|
||||
found_el = self.marionette.find_element("id", "main-window")
|
||||
el = self.marionette.execute_script("return window.document.getElementById('textInput');")
|
||||
found_el = self.marionette.find_element("id", "textInput")
|
||||
self.assertEqual(HTMLElement, type(found_el))
|
||||
self.assertTrue(el.id, found_el.id)
|
||||
self.assertEqual(el.id, found_el.id)
|
||||
|
||||
def test_child_element(self):
|
||||
el = self.marionette.find_element("id", "textInput")
|
||||
parent = self.marionette.find_element("id", "things")
|
||||
found_el = parent.find_element("tag name", "textbox")
|
||||
self.assertEqual(HTMLElement, type(found_el))
|
||||
self.assertEqual(el.id, found_el.id)
|
||||
|
||||
def test_child_elements(self):
|
||||
el = self.marionette.find_element("id", "textInput3")
|
||||
parent = self.marionette.find_element("id", "things")
|
||||
found_els = parent.find_elements("tag name", "textbox")
|
||||
self.assertTrue(el.id in [found_el.id for found_el in found_els])
|
||||
|
||||
def test_tag_name(self):
|
||||
el = self.marionette.execute_script("return window.document.getElementsByTagName('window')[0];")
|
||||
found_el = self.marionette.find_element("tag name", "window")
|
||||
el = self.marionette.execute_script("return window.document.getElementsByTagName('vbox')[0];")
|
||||
found_el = self.marionette.find_element("tag name", "vbox")
|
||||
self.assertEqual(HTMLElement, type(found_el))
|
||||
self.assertTrue(el.id, found_el.id)
|
||||
self.assertEqual(el.id, found_el.id)
|
||||
|
||||
def test_class_name(self):
|
||||
el = self.marionette.execute_script("return window.document.getElementsByClassName('editBookmarkPanelHeaderButton')[0];")
|
||||
found_el = self.marionette.find_element("class name", "editBookmarkPanelHeaderButton")
|
||||
el = self.marionette.execute_script("return window.document.getElementsByClassName('asdf')[0];")
|
||||
found_el = self.marionette.find_element("class name", "asdf")
|
||||
self.assertEqual(HTMLElement, type(found_el));
|
||||
self.assertTrue(el.id, found_el.id)
|
||||
self.assertEqual(el.id, found_el.id)
|
||||
|
||||
def test_xpath(self):
|
||||
el = self.marionette.execute_script("return window.document.getElementById('main-window');")
|
||||
found_el = self.marionette.find_element("xpath", "id('main-window')")
|
||||
el = self.marionette.execute_script("return window.document.getElementById('testBox');")
|
||||
found_el = self.marionette.find_element("xpath", "id('testBox')")
|
||||
self.assertEqual(HTMLElement, type(found_el));
|
||||
self.assertTrue(el.id, found_el.id)
|
||||
self.assertEqual(el.id, found_el.id)
|
||||
|
||||
def test_not_found(self):
|
||||
self.assertRaises(NoSuchElementException, self.marionette.find_element, "id", "I'm not on the page")
|
||||
|
@ -152,6 +194,6 @@ class TestElementsChrome(MarionetteTestCase):
|
|||
def test_timeout(self):
|
||||
self.assertRaises(NoSuchElementException, self.marionette.find_element, "id", "myid")
|
||||
self.assertTrue(True, self.marionette.set_search_timeout(4000))
|
||||
self.marionette.execute_script("window.setTimeout(function() {var b = window.document.createElement('button'); b.id = 'myid'; document.getElementById('main-window').appendChild(b);}, 1000)")
|
||||
self.marionette.execute_script("window.setTimeout(function() {var b = window.document.createElement('button'); b.id = 'myid'; document.getElementById('things').appendChild(b);}, 1000)")
|
||||
self.assertEqual(HTMLElement, type(self.marionette.find_element("id", "myid")))
|
||||
self.marionette.execute_script("window.document.getElementById('main-window').removeChild(window.document.getElementById('myid'));")
|
||||
self.marionette.execute_script("window.document.getElementById('things').removeChild(window.document.getElementById('myid'));")
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/ #
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is Marionette Client.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Mozilla Foundation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 2011
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
import os
|
||||
from marionette_test import MarionetteTestCase
|
||||
|
||||
class TestGetAttribute(MarionetteTestCase):
|
||||
def test_getAttribute(self):
|
||||
test_html = self.marionette.absolute_url("test.html")
|
||||
self.marionette.navigate(test_html)
|
||||
l = self.marionette.find_element("id", "mozLink")
|
||||
self.assertEqual("mozLink", l.get_attribute("id"))
|
||||
|
||||
class TestGetAttributeChrome(MarionetteTestCase):
|
||||
def setUp(self):
|
||||
MarionetteTestCase.setUp(self)
|
||||
self.marionette.set_context("chrome")
|
||||
self.win = self.marionette.get_window()
|
||||
#need to get the file:// path for xul
|
||||
unit = os.path.abspath(os.path.join(os.path.realpath(__file__), os.path.pardir))
|
||||
tests = os.path.abspath(os.path.join(unit, os.path.pardir))
|
||||
mpath = os.path.abspath(os.path.join(tests, os.path.pardir))
|
||||
xul = "file://" + os.path.join(mpath, "www", "test.xul")
|
||||
self.marionette.execute_script("window.open('" + xul +"', '_blank', 'chrome,centerscreen');")
|
||||
|
||||
def tearDown(self):
|
||||
self.marionette.execute_script("window.close();")
|
||||
self.marionette.switch_to_window(self.win)
|
||||
MarionetteTestCase.tearDown(self)
|
||||
|
||||
def test_getAttribute(self):
|
||||
el = self.marionette.execute_script("return window.document.getElementById('textInput');")
|
||||
found_el = self.marionette.find_element("id", "textInput")
|
||||
self.assertEqual(el.get_attribute("id"), "textInput")
|
||||
|
|
@ -0,0 +1,73 @@
|
|||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/ #
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is Marionette Client.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Mozilla Foundation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 2011
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
import os
|
||||
from marionette_test import MarionetteTestCase
|
||||
|
||||
class TestSelected(MarionetteTestCase):
|
||||
def test_selected(self):
|
||||
test_html = self.marionette.absolute_url("test.html")
|
||||
self.marionette.navigate(test_html)
|
||||
box = self.marionette.find_element("name", "myCheckBox")
|
||||
self.assertFalse(box.selected())
|
||||
box.click()
|
||||
self.assertTrue(box.selected())
|
||||
|
||||
class TestSelectedChrome(MarionetteTestCase):
|
||||
def setUp(self):
|
||||
MarionetteTestCase.setUp(self)
|
||||
self.marionette.set_context("chrome")
|
||||
self.win = self.marionette.get_window()
|
||||
#need to get the file:// path for xul
|
||||
unit = os.path.abspath(os.path.join(os.path.realpath(__file__), os.path.pardir))
|
||||
tests = os.path.abspath(os.path.join(unit, os.path.pardir))
|
||||
mpath = os.path.abspath(os.path.join(tests, os.path.pardir))
|
||||
xul = "file://" + os.path.join(mpath, "www", "test.xul")
|
||||
self.marionette.execute_script("window.open('" + xul +"', '_blank', 'chrome,centerscreen');")
|
||||
|
||||
def tearDown(self):
|
||||
self.marionette.execute_script("window.close();")
|
||||
self.marionette.switch_to_window(self.win)
|
||||
MarionetteTestCase.tearDown(self)
|
||||
|
||||
def test_selected(self):
|
||||
wins = self.marionette.get_windows()
|
||||
wins.remove(self.win)
|
||||
newWin = wins.pop()
|
||||
self.marionette.switch_to_window(newWin)
|
||||
box = self.marionette.find_element("id", "testBox")
|
||||
self.assertFalse(box.selected())
|
||||
self.assertFalse(self.marionette.execute_script("arguments[0].checked = true;", [box]))
|
||||
self.assertTrue(box.selected())
|
|
@ -0,0 +1,105 @@
|
|||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/ #
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is Marionette Client.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Mozilla Foundation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 2011
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
import os
|
||||
from marionette_test import MarionetteTestCase
|
||||
|
||||
class TestText(MarionetteTestCase):
|
||||
def test_getText(self):
|
||||
test_html = self.marionette.absolute_url("test.html")
|
||||
self.marionette.navigate(test_html)
|
||||
l = self.marionette.find_element("id", "mozLink")
|
||||
self.assertEqual("Click me!", l.text())
|
||||
|
||||
def test_clearText(self):
|
||||
test_html = self.marionette.absolute_url("test.html")
|
||||
self.marionette.navigate(test_html)
|
||||
l = self.marionette.find_element("name", "myInput")
|
||||
self.assertEqual("asdf", self.marionette.execute_script("return arguments[0].value;", [l]))
|
||||
l.clear()
|
||||
self.assertEqual("", self.marionette.execute_script("return arguments[0].value;", [l]))
|
||||
|
||||
def test_sendKeys(self):
|
||||
test_html = self.marionette.absolute_url("test.html")
|
||||
self.marionette.navigate(test_html)
|
||||
l = self.marionette.find_element("name", "myInput")
|
||||
self.assertEqual("asdf", self.marionette.execute_script("return arguments[0].value;", [l]))
|
||||
l.send_keys("o")
|
||||
self.assertEqual("asdfo", self.marionette.execute_script("return arguments[0].value;", [l]))
|
||||
|
||||
class TestTextChrome(MarionetteTestCase):
|
||||
def setUp(self):
|
||||
MarionetteTestCase.setUp(self)
|
||||
self.marionette.set_context("chrome")
|
||||
self.win = self.marionette.get_window()
|
||||
#need to get the file:// path for xul
|
||||
unit = os.path.abspath(os.path.join(os.path.realpath(__file__), os.path.pardir))
|
||||
tests = os.path.abspath(os.path.join(unit, os.path.pardir))
|
||||
mpath = os.path.abspath(os.path.join(tests, os.path.pardir))
|
||||
xul = "file://" + os.path.join(mpath, "www", "test.xul")
|
||||
self.marionette.execute_script("window.open('" + xul +"', '_blank', 'chrome,centerscreen');")
|
||||
|
||||
def tearDown(self):
|
||||
self.marionette.execute_script("window.close();")
|
||||
self.marionette.switch_to_window(self.win)
|
||||
MarionetteTestCase.tearDown(self)
|
||||
|
||||
def test_getText(self):
|
||||
wins = self.marionette.get_windows()
|
||||
wins.remove(self.win)
|
||||
newWin = wins.pop()
|
||||
self.marionette.switch_to_window(newWin)
|
||||
box = self.marionette.find_element("id", "textInput")
|
||||
self.assertEqual("test", box.text())
|
||||
|
||||
def test_clearText(self):
|
||||
wins = self.marionette.get_windows()
|
||||
wins.remove(self.win)
|
||||
newWin = wins.pop()
|
||||
self.marionette.switch_to_window(newWin)
|
||||
box = self.marionette.find_element("id", "textInput")
|
||||
self.assertEqual("test", box.text())
|
||||
box.clear()
|
||||
self.assertEqual("", box.text())
|
||||
|
||||
def test_sendKeys(self):
|
||||
wins = self.marionette.get_windows()
|
||||
wins.remove(self.win)
|
||||
newWin = wins.pop()
|
||||
self.marionette.switch_to_window(newWin)
|
||||
box = self.marionette.find_element("id", "textInput")
|
||||
self.assertEqual("test", box.text())
|
||||
box.send_keys("at")
|
||||
self.assertEqual("attest", box.text())
|
|
@ -1,5 +1,13 @@
|
|||
[test_click.py]
|
||||
b2g = false
|
||||
[test_selected.py]
|
||||
b2g = false
|
||||
[test_getattr.py]
|
||||
b2g = false
|
||||
[test_elementState.py]
|
||||
b2g = false
|
||||
[test_text.py]
|
||||
b2g = false
|
||||
|
||||
[test_log.py]
|
||||
[test_execute_async_script.py]
|
||||
|
|
|
@ -21,7 +21,11 @@
|
|||
}
|
||||
</script>
|
||||
<a href="#" id="mozLink" class="linkClass" onclick="clicked()">Click me!</a>
|
||||
<a href="#" id="mozLink" class="linkClass" onclick="clicked()">Click me!</a>
|
||||
<input name="myInput" type="text" />
|
||||
<div id="testDiv">
|
||||
<a href="#" id="divLink" class="linkClass" onclick="clicked()">Div click me!</a>
|
||||
<a href="#" id="divLink2" class="linkClass" onclick="clicked()">Div click me!</a>
|
||||
</div>
|
||||
<input name="myInput" type="text" value="asdf"/>
|
||||
<input name="myCheckBox" type="checkbox" />
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE window [
|
||||
]>
|
||||
|
||||
<dialog id="dia"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
|
||||
<vbox id="things">
|
||||
<checkbox id="testBox" label="box" />
|
||||
<textbox id="textInput" size="6" value="test" label="input" />
|
||||
<textbox id="textInput2" size="6" value="test" label="input" />
|
||||
<textbox id="textInput3" class="asdf" size="6" value="test" label="input" />
|
||||
</vbox>
|
||||
|
||||
</dialog>
|
Загрузка…
Ссылка в новой задаче