-
Notifications
You must be signed in to change notification settings - Fork 783
Expand file tree
/
Copy pathtest_keyword_arguments_element.py
More file actions
51 lines (39 loc) · 1.75 KB
/
test_keyword_arguments_element.py
File metadata and controls
51 lines (39 loc) · 1.75 KB
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
import pytest
from mockito import mock, unstub, when
from SeleniumLibrary.keywords import ElementKeywords
@pytest.fixture(scope="function")
def element():
ctx = mock()
ctx._browser = mock()
return ElementKeywords(ctx)
def teardown_function():
unstub()
def test_element_text_should_be(element):
locator = "//div"
webelement = mock()
webelement.text = "text"
when(element).find_element(locator).thenReturn(webelement)
with pytest.raises(AssertionError) as error:
element.element_text_should_be(locator, "not text")
assert "should have been" in str(error.value)
with pytest.raises(AssertionError) as error:
element.element_text_should_be(locator, "not text", "foobar")
assert "foobar" in str(error.value)
webelement.text = "text "
when(element).find_element(locator).thenReturn(webelement)
with pytest.raises(AssertionError) as error:
element.element_text_should_be(locator, "text", strip_spaces=False)
assert "should have been" in str(error.value)
with pytest.raises(AssertionError) as error:
element.element_text_should_be(locator, "text", strip_spaces="LEADING")
assert "should have been" in str(error.value)
webelement.text = " text"
when(element).find_element(locator).thenReturn(webelement)
with pytest.raises(AssertionError) as error:
element.element_text_should_be(locator, "text", strip_spaces="TRAILING")
assert "should have been" in str(error.value)
webelement.text = "testing is cool"
when(element).find_element(locator).thenReturn(webelement)
with pytest.raises(AssertionError) as error:
element.element_text_should_be(locator, "testing is cool", collapse_spaces=False)
assert "should have been" in str(error.value)