зеркало из https://github.com/mozilla/kitsune.git
Merge pull request #6296 from emilghittasv/playwright-block-pontoon-requests
Playwright block Pontoon requests
This commit is contained in:
Коммит
b494d09f0e
|
@ -196,7 +196,7 @@ class MyProfileEdit(BasePage):
|
|||
self._click(self.__cancel_button)
|
||||
|
||||
def click_update_my_profile_button(self):
|
||||
self._click(self.__update_my_profile_button)
|
||||
self._click(self.__update_my_profile_button, with_force=True)
|
||||
|
||||
def click_close_account_option(self):
|
||||
self._click(self.__close_account_and_delete_all_profile_information_link)
|
||||
|
|
|
@ -2,32 +2,60 @@ import allure
|
|||
import pytest
|
||||
from playwright.sync_api import Page
|
||||
from slugify import slugify
|
||||
|
||||
from playwright_tests.messages.homepage_messages import HomepageMessages
|
||||
|
||||
|
||||
def _block_request(route):
|
||||
"""
|
||||
This function blocks a certain request
|
||||
"""
|
||||
route.abort()
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def navigate_to_homepage(page: Page):
|
||||
"""
|
||||
This fixture is used in all functions. It navigates to the SuMo homepage and returns the page
|
||||
object.
|
||||
"""
|
||||
|
||||
# Set default navigation timeout to 2 minutes.
|
||||
page.set_default_navigation_timeout(120000)
|
||||
|
||||
# Block pontoon requests in the current page context.
|
||||
page.route("**/pontoon.mozilla.org/**", _block_request)
|
||||
|
||||
# Navigate to the SUMO stage homepage.
|
||||
page.goto(HomepageMessages.STAGE_HOMEPAGE_URL)
|
||||
|
||||
return page
|
||||
|
||||
|
||||
def pytest_runtest_makereport(item, call) -> None:
|
||||
"""
|
||||
If there is a test failure we are saving & attaching the test execution's screencast to
|
||||
allure reporting.
|
||||
This pytest hook is triggered after each test execution.
|
||||
If a test failure occurred we are saving & attaching the test execution screencast to the
|
||||
allure report for better debugging.
|
||||
"""
|
||||
if call.when == "call":
|
||||
# Check if the test has raised an exception (test failed or encountered an error during
|
||||
# execution). Also checks if the test function has the page instance in its arguments
|
||||
# ensuring that video recording is applied only when the test involves playwright
|
||||
# automation.
|
||||
if call.excinfo is not None and "page" in item.funcargs:
|
||||
# Retrieve the page object from the test function arguments.
|
||||
page: Page = item.funcargs["page"]
|
||||
|
||||
# Provide the path to the recorded video (the video recording starts when the browser
|
||||
# context is created).
|
||||
video_path = page.video.path()
|
||||
page.context.close() # ensure video saved
|
||||
# Ensure that the browser context is closed after test. Closing the context also
|
||||
# ensures that the video is properly saved.
|
||||
page.context.close()
|
||||
# Attaching the video to the Allure report:
|
||||
# 1. Opening the video file in binary mode and reading its content.
|
||||
# 2. Assigning a name to the video attachment based on the slugyfied version of the
|
||||
# test node id.
|
||||
# 3. Saving the video as a .webm extension.
|
||||
allure.attach(
|
||||
open(video_path, 'rb').read(),
|
||||
name=f"{slugify(item.nodeid)}.webm",
|
||||
|
|
|
@ -185,8 +185,8 @@ def test_my_question_page_reflects_posted_questions_and_redirects_to_the_correct
|
|||
with allure.step("Navigating to my questions profile page and verifying that the first "
|
||||
"element from the My Questions page is the recently posted question"):
|
||||
sumo_pages.top_navbar.click_on_my_questions_profile_option()
|
||||
assert sumo_pages.my_questions_page._get_text_of_first_listed_question().replace(
|
||||
" ", "") == question_info["aaq_subject"].replace(" ", "")
|
||||
assert sumo_pages.my_questions_page._get_text_of_first_listed_question(
|
||||
).strip() == question_info["aaq_subject"].strip()
|
||||
|
||||
with allure.step("Clicking on the first list item and verifying that the user is "
|
||||
"redirected to the correct question"):
|
||||
|
|
Загрузка…
Ссылка в новой задаче