From 4f7525fe3920b370ac319259c023bfcabd1eb572 Mon Sep 17 00:00:00 2001 From: Elena7788 Date: Thu, 17 Jun 2021 19:29:08 +0300 Subject: [PATCH 1/2] Improved tests structure in element__element__lazy_search_test.py and element__lazy_search_test.py --- .../element__element__lazy_search_test.py | 27 +++++++++------ .../integration/element__lazy_search_test.py | 34 +++++++++++++++---- 2 files changed, 44 insertions(+), 17 deletions(-) diff --git a/tests/integration/element__element__lazy_search_test.py b/tests/integration/element__element__lazy_search_test.py index 07ea364a..74ad31b4 100644 --- a/tests/integration/element__element__lazy_search_test.py +++ b/tests/integration/element__element__lazy_search_test.py @@ -37,9 +37,9 @@ def test_search_does_not_start_on_creation_for_both_parent_and_inner( def test_search_is_postponed_until_actual_action_like_questioning_displayed( session_browser, ): - element = session_browser.element('#will-be-existing-element').element( - '.will-exist-inner' - ) + element = session_browser.element( + '#will-be-existing-element' + ).element('.will-exist-inner') page = GivenPage(session_browser.driver) page.opened_empty() @@ -47,7 +47,8 @@ def test_search_is_postponed_until_actual_action_like_questioning_displayed( '''

Hello kitty:* -

''' + + ''' ) answer = element().is_displayed() @@ -57,10 +58,11 @@ def test_search_is_postponed_until_actual_action_like_questioning_displayed( def test_search_is_updated_on_next_actual_action_like_questioning_displayed( session_browser, ): - element = session_browser.element('#will-be-existing-element').element( - '.will-exist-inner' - ) + element = session_browser.element( + '#will-be-existing-element' + ).element('.will-exist-inner') page = GivenPage(session_browser.driver) + page.opened_with_body( '''

@@ -68,6 +70,7 @@ def test_search_is_updated_on_next_actual_action_like_questioning_displayed(

''' ) + assert element().is_displayed() is True page.load_body( @@ -76,14 +79,17 @@ def test_search_is_updated_on_next_actual_action_like_questioning_displayed( kitty:* - ''' + + ''' ) new_answer = element().is_displayed() assert new_answer is False -def test_search_finds_exactly_inside_parent(session_browser): +def test_search_finds_exactly_inside_parent( + session_browser, +): page = GivenPage(session_browser.driver) page.opened_with_body( ''' @@ -92,7 +98,8 @@ def test_search_finds_exactly_inside_parent(session_browser): go to Heading 2

Heading 1

Heading 2

- /p>''' + /p> + ''' ) session_browser.element('p').element('a').click() diff --git a/tests/integration/element__lazy_search_test.py b/tests/integration/element__lazy_search_test.py index efdb42f2..74b39c7c 100644 --- a/tests/integration/element__lazy_search_test.py +++ b/tests/integration/element__lazy_search_test.py @@ -23,11 +23,14 @@ from tests.integration.helpers.givenpage import GivenPage -def test_search_does_not_start_on_creation(session_browser): +def test_search_does_not_start_on_creation( + session_browser, +): page = GivenPage(session_browser.driver) page.opened_empty() - non_existent_element = session_browser.element('#not-existing-element-id') + non_existent_element = session_browser.element( + '#not-existing-element-id') assert str(non_existent_element) @@ -38,8 +41,14 @@ def test_search_is_postponed_until_actual_action_like_questioning_displayed( page = GivenPage(session_browser.driver) page.opened_empty() - element = session_browser.element('#will-be-existing-element-id') - page.load_body('

Hello kitty:*

') + element = session_browser.element( + '#will-be-existing-element-id') + page.load_body( + ''' +

Hello kitty:* +

+ ''' + ) assert element().is_displayed() is True @@ -50,11 +59,22 @@ def test_search_is_updated_on_next_actual_action_like_questioning_displayed( page = GivenPage(session_browser.driver) page.opened_empty() - element = session_browser.element('#will-be-existing-element-id') - page.load_body('

Hello kitty:*

') + element = session_browser.element( + '#will-be-existing-element-id') + page.load_body( + ''' +

Hello kitty: + *

+ ''' + ) + assert element().is_displayed() is True page.load_body( - '

Hello kitty:*

' + ''' +

Hello kitty: + *

+ ''' ) + assert element().is_displayed() is False From 2b3e068ed32a63f8fd5661f4f69ad2a6d6772a26 Mon Sep 17 00:00:00 2001 From: Elena7788 Date: Sun, 20 Jun 2021 14:30:20 +0300 Subject: [PATCH 2/2] [#352][#353] TEST: Refactoring of test structure after review --- .../element__element__lazy_search_test.py | 43 +++++++---------- .../integration/element__lazy_search_test.py | 47 ++++++++----------- 2 files changed, 37 insertions(+), 53 deletions(-) diff --git a/tests/integration/element__element__lazy_search_test.py b/tests/integration/element__element__lazy_search_test.py index 74ad31b4..5b29c636 100644 --- a/tests/integration/element__element__lazy_search_test.py +++ b/tests/integration/element__element__lazy_search_test.py @@ -25,7 +25,8 @@ def test_search_does_not_start_on_creation_for_both_parent_and_inner( session_browser, ): - GivenPage(session_browser.driver).opened_empty() + page = GivenPage(session_browser.driver) + page.opened_empty() non_existent_element = session_browser.element( '#not-existing-element' @@ -37,32 +38,30 @@ def test_search_does_not_start_on_creation_for_both_parent_and_inner( def test_search_is_postponed_until_actual_action_like_questioning_displayed( session_browser, ): - element = session_browser.element( - '#will-be-existing-element' - ).element('.will-exist-inner') + element = session_browser.element('#will-be-existing-element').element( + '.will-exist-inner' + ) page = GivenPage(session_browser.driver) - page.opened_empty() - - page.load_body( + page.opened_with_body( '''

Hello kitty:*

''' ) - answer = element().is_displayed() - assert answer is True + until_actual_action = element().is_displayed() + + assert until_actual_action is True def test_search_is_updated_on_next_actual_action_like_questioning_displayed( session_browser, ): - element = session_browser.element( - '#will-be-existing-element' - ).element('.will-exist-inner') + element = session_browser.element('#will-be-existing-element').element( + '.will-exist-inner' + ) page = GivenPage(session_browser.driver) - page.opened_with_body( '''

@@ -70,26 +69,20 @@ def test_search_is_updated_on_next_actual_action_like_questioning_displayed(

''' ) - - assert element().is_displayed() is True - page.load_body( '''

- kitty:* + kitty:*

''' ) - new_answer = element().is_displayed() - assert new_answer is False + updated_actual_action = element().is_displayed() + assert updated_actual_action is False -def test_search_finds_exactly_inside_parent( - session_browser, -): + +def test_search_finds_exactly_inside_parent(session_browser): page = GivenPage(session_browser.driver) page.opened_with_body( ''' @@ -98,7 +91,7 @@ def test_search_finds_exactly_inside_parent( go to Heading 2

Heading 1

Heading 2

- /p> +

''' ) diff --git a/tests/integration/element__lazy_search_test.py b/tests/integration/element__lazy_search_test.py index 74b39c7c..909e7fe4 100644 --- a/tests/integration/element__lazy_search_test.py +++ b/tests/integration/element__lazy_search_test.py @@ -23,14 +23,11 @@ from tests.integration.helpers.givenpage import GivenPage -def test_search_does_not_start_on_creation( - session_browser, -): +def test_search_does_not_start_on_creation(session_browser): page = GivenPage(session_browser.driver) page.opened_empty() - non_existent_element = session_browser.element( - '#not-existing-element-id') + non_existent_element = session_browser.element('#not-existing-element-id') assert str(non_existent_element) @@ -40,17 +37,16 @@ def test_search_is_postponed_until_actual_action_like_questioning_displayed( ): page = GivenPage(session_browser.driver) page.opened_empty() - - element = session_browser.element( - '#will-be-existing-element-id') + element = session_browser.element('#will-be-existing-element-id') page.load_body( - ''' -

Hello kitty:* -

- ''' + '

' + 'Hello kitty:*' + '

' ) - assert element().is_displayed() is True + until_actual_action = element().is_displayed() + + assert until_actual_action is True def test_search_is_updated_on_next_actual_action_like_questioning_displayed( @@ -58,23 +54,18 @@ def test_search_is_updated_on_next_actual_action_like_questioning_displayed( ): page = GivenPage(session_browser.driver) page.opened_empty() - - element = session_browser.element( - '#will-be-existing-element-id') + element = session_browser.element('#will-be-existing-element-id') page.load_body( - ''' -

Hello kitty: - *

- ''' + '

' + 'Hello kitty:*' + '

' ) - - assert element().is_displayed() is True - page.load_body( - ''' -

Hello kitty: - *

- ''' + '

' + 'Hello kitty:*' + '

' ) - assert element().is_displayed() is False + updated_actual_action = element().is_displayed() + + assert updated_actual_action is False