Skip to content

Commit

Permalink
assert_screenshot + hide fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
VladimirPodolian committed Dec 24, 2024
1 parent ccde265 commit 00abbc8
Show file tree
Hide file tree
Showing 17 changed files with 49 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/selenium_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ jobs:
- name: Run Selenium ${{ env.BROWSER }} tests with py${{ matrix.python-version }}
run: |
tox -e py${{ env.TOX_ENV }}-selenium-${{ env.BROWSER }} -- --env remote --headless -v --sv
tox -e py${{ env.TOX_ENV }}-selenium-${{ env.BROWSER }} -- --env remote --headless -v
20 changes: 20 additions & 0 deletions tests/adata/pages/colored_blocks_page.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from typing import List

from dyatel.base.element import Element
from dyatel.base.page import Page
from tests.settings import domain_name, repo_name


class ColoredBlocksPage(Page):

def __init__(self):
super().__init__('colored-blocks-page', name='Colored blocks page')

url = f'{domain_name}/{repo_name}/colored_blocks.html'

blocks_container = Element('.container', name='colored blocks container')
card = Element('.card', name='any colored block')
navbar = Element('.navbar', name='navbar')

def get_all_cards(self) -> List[Element]:
return self.card.all_elements
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from dyatel.visual_comparison import VisualComparison
from tests.adata.drivers.driver_entities import DriverEntities
from tests.adata.drivers.driver_factory import DriverFactory
from tests.adata.pages.colored_blocks_page import ColoredBlocksPage
from tests.adata.pages.expected_condition_page import ExpectedConditionPage
from tests.adata.pages.forms_page import FormsPage
from tests.adata.pages.frames_page import FramesPage
Expand Down Expand Up @@ -67,6 +68,8 @@ def chrome_options(request):
options.add_argument("--disable-gpu")
options.add_argument("--remote-allow-origins=*")
options.add_argument("--disable-dev-shm-usage")
options.add_experimental_option("excludeSwitches", ["enable-automation"])
options.add_experimental_option("useAutomationExtension", False)
options.set_capability('goog:loggingPrefs', {'performance': 'ALL'})
return options

Expand Down Expand Up @@ -141,6 +144,11 @@ def second_playground_page(driver_wrapper):
return SecondPlaygroundMainPage().open_page()


@pytest.fixture
def colored_blocks_page(driver_wrapper):
return ColoredBlocksPage().open_page()


@pytest.fixture
def pizza_order_page(driver_wrapper):
return PizzaOrderPage().open_page()
Expand Down
37 changes: 20 additions & 17 deletions tests/web_tests/test_assert_screenshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,34 +81,37 @@ def test_append_dummy_elements_multiple_available(second_playground_page, driver
VisualComparison(driver_wrapper)._appends_dummy_elements([Card()])


def test_assert_screenshot_hide_elements(second_playground_page, driver_wrapper):
all_cards = second_playground_page.get_all_cards()
second_playground_page.row_with_cards.assert_screenshot(
def test_assert_screenshot_hide_elements(colored_blocks_page, driver_wrapper):
all_cards = colored_blocks_page.get_all_cards()
colored_blocks_page.blocks_container.assert_screenshot(
hide=all_cards[1],
name_suffix='middle hidden'
name_suffix='middle hidden',
delay=0.5
)
driver_wrapper.refresh()
second_playground_page.row_with_cards.scroll_into_view()
all_cards = second_playground_page.get_all_cards()
second_playground_page.row_with_cards.assert_screenshot(
all_cards = colored_blocks_page.get_all_cards()
colored_blocks_page.blocks_container.assert_screenshot(
hide=[all_cards[0], all_cards[2]],
name_suffix='sides hidden'
name_suffix='sides hidden',
delay=0.5
)


def test_assert_screenshot_hide_driver_elements(second_playground_page, driver_wrapper):
all_cards = second_playground_page.get_all_cards()
second_playground_page.row_with_cards.scroll_into_view()
def test_assert_screenshot_hide_driver_elements(colored_blocks_page, driver_wrapper):
all_cards = colored_blocks_page.get_all_cards()
colored_blocks_page.blocks_container.scroll_into_view()
driver_wrapper.assert_screenshot(
hide=all_cards[1],
name_suffix='middle hidden'
hide=[all_cards[1]] + colored_blocks_page.navbar.all_elements,
name_suffix='middle hidden',
delay=0.5,
)
driver_wrapper.refresh()
second_playground_page.row_with_cards.scroll_into_view()
all_cards = second_playground_page.get_all_cards()
colored_blocks_page.blocks_container.scroll_into_view()
all_cards = colored_blocks_page.get_all_cards()
driver_wrapper.assert_screenshot(
hide=[all_cards[0], all_cards[2]],
name_suffix='sides hidden'
hide=[all_cards[0], all_cards[2]] + colored_blocks_page.navbar.all_elements,
name_suffix='sides hidden',
delay=0.5,
)


Expand Down

0 comments on commit 00abbc8

Please sign in to comment.