forked from cobrateam/splinter
-
Notifications
You must be signed in to change notification settings - Fork 1
/
type.py
60 lines (48 loc) · 2.35 KB
/
type.py
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# -*- coding: utf-8 -*-
# Copyright 2012 splinter authors. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
from .fake_webapp import EXAMPLE_APP
class SlowlyTypeTest(object):
def test_simple_type(self):
"should provide a away to change field value using type method"
self.browser.visit(EXAMPLE_APP)
self.browser.type('query', ' with type method')
value = self.browser.find_by_name('query').value
self.assertEqual('default value with type method', value)
self.browser.type('description', 'type into textarea')
value = self.browser.find_by_name('description').value
self.assertEqual('type into textarea', value)
def test_simple_type_on_element(self):
self.browser.visit(EXAMPLE_APP)
self.browser.find_by_name('query').type(' with type method')
value = self.browser.find_by_name('query').value
self.assertEqual('default value with type method', value)
self.browser.find_by_name('description').type('type into textarea')
value = self.browser.find_by_name('description').value
self.assertEqual('type into textarea', value)
def test_slowly_typing(self):
"should be able to slowly type some text in a field"
for name in ['type-input', 'type-textarea']:
self.browser.visit(EXAMPLE_APP + 'type')
num = 0
num_max = 6
for key in self.browser.type(name, 'typing', slowly=True):
self.assertEqual(self.browser.is_text_present("#%d" % num), True)
num += 1
self.assertEqual(num, num_max)
element = self.browser.find_by_name(name)
self.assertEqual(element.value, 'typing')
def test_slowly_typing_on_element(self):
for name in ['type-input', 'type-textarea']:
self.browser.visit(EXAMPLE_APP + 'type')
num = 0
num_max = 6
text_input = self.browser.find_by_name(name)
typing = text_input.type('typing', slowly=True)
for key in typing:
self.assertEqual(self.browser.is_text_present("#%d" % num), True)
num += 1
self.assertEqual(num, num_max)
element = self.browser.find_by_name(name)
self.assertEqual(element.value, 'typing')