Skip to content

Commit

Permalink
Merge pull request #6262 from emilghittasv/playwright-fix-failing-tests
Browse files Browse the repository at this point in the history
Playwright fix failing tests
  • Loading branch information
emilghittasv authored Oct 1, 2024
2 parents 77c1dc0 + eb20b7a commit 33e0f6f
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 24 deletions.
6 changes: 3 additions & 3 deletions playwright_tests/core/basepage.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,16 @@ def _get_text_content_of_all_locators(self, locator: Locator) -> list[str]:
"""
return locator.all_text_contents()

def _click(self, element: Union[str, Locator], with_wait=True):
def _click(self, element: Union[str, Locator], with_wait=True, with_force=False):
"""
This helper function clicks on a given element locator.
"""
if isinstance(element, str):
if with_wait:
self._wait_for_selector(element)
self._get_element_locator(element).click()
self._get_element_locator(element).click(force=with_force)
elif isinstance(element, Locator):
element.click()
element.click(force=with_force)

def _click_on_an_element_by_index(self, xpath: str, index: int):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class ContactSupportMessages:
"data breach.",
"Pocket": "Discover and save stories for later.",
"Thunderbird": "Email software for Windows, Mac and Linux",
"Thunderbird for Android": "Email app for Android smartphones and tablets",
"Firefox Focus": "Automatic privacy browser and content blocker",
"Mozilla Account": "Privacy-first products for desktop and mobile"
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
class ModerateForumContentPageMessages:
UPDATE_STATUS_FIRST_VALUE = "The flag is valid and I fixed the issue."
UPDATE_STATUS_SECOND_VALUE = "The flag is invalid."
UPDATE_STATUS_FIRST_VALUE = "1"
UPDATE_STATUS_SECOND_VALUE = "2"
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,8 @@ def click_on_email_me_when_someone_answers_the_thread_checkbox(self):
def click_aaq_form_cancel_button(self):
self._click(self.__form_cancel_option)

def click_aaq_form_submit_button(self):
self._click(self.__form_submit_button)
def click_aaq_form_submit_button(self, with_force=False):
self._click(self.__form_submit_button, with_force)

# Edit question form actions.
def click_aaq_edit_submit_button(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@


class ModerateForumContent(BasePage):

# View all deactivated users button
__view_all_deactivated_users_button = "//div[@class='sumo-button-wrap']/a"

Expand Down Expand Up @@ -47,11 +46,11 @@ def _click_take_action_delete_option(self, question_title: str):
super()._click(f"//p[text()='{question_title}']/following-sibling::div/a[text()='Delete']")

def _select_update_status_option(self, question_title: str, select_value: str):
super()._select_option_by_label(f"//p[text()='{question_title}']/"
super()._select_option_by_value(f"//p[text()='{question_title}']/../"
f"following-sibling::form/select", select_value)

def _click_on_the_update_button(self, questions_title: str):
super()._click(f"//p[text()='{questions_title}']/following-sibling::form/"
super()._click(f"//p[text()='{questions_title}']/../following-sibling::form/"
f"input[@value='Update']")

def _click_view_all_deactivated_users_button(self):
Expand Down
4 changes: 2 additions & 2 deletions playwright_tests/pages/user_pages/my_profile_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ class MyProfilePage(BasePage):
__private_message_button = "//p[@class='pm']/a"

# Report Abuse
__report_abuse_panel = "//section[@id='report-abuse']"
__report_abuse_panel = "//section[@id='report-abuse-']"
__spam_or_other_unrelated_content_option = ("//label[contains(text(),'Spam or other unrelated "
"content')]")
__inappropriate_language_or_dialog_option = ("//label[contains(text(),'Inappropriate "
"language/dialog')]")
__other_please_specify_option = "//label[contains(text(),'Other (please specify)')]"
__have_more_to_say_textarea = "//textarea[@name='other']"
__report_abuse_close_panel_button = "//div[@class='mzp-c-modal-close']/button"
__report_abuse_submit_button = "//section[@id='report-abuse']//button[@type='submit']"
__report_abuse_submit_button = "//section[@id='report-abuse-']//button[@type='submit']"
__reported_user_confirmation_message = "//span[@class='message']"

# Contributions section
Expand Down
8 changes: 8 additions & 0 deletions playwright_tests/test_data/aaq_question.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"Firefox Relay": "https://support.allizom.org/en-US/questions/new/relay/form",
"Pocket": "https://support.allizom.org/en-US/questions/new/pocket/form",
"Thunderbird": "https://support.allizom.org/en-US/questions/new/thunderbird/form",
"Thunderbird for Android": "https://support.allizom.org/en-US/questions/new/thunderbird-android/form",
"Firefox Focus": "https://support.allizom.org/en-US/questions/new/focus-firefox/form",
"Mozilla Account": "https://support.allizom.org/en-US/questions/new/mozilla-account/form"
},
Expand Down Expand Up @@ -99,6 +100,13 @@
"Settings": "settings",
"default_slug": "none"
},
"Thunderbird for Android": {
"Email and messaging": "email-and-messaging",
"Installation and updates": "installation-and-updates",
"Privacy and security": "privacy-and-security",
"Settings": "settings",
"default_slug": "thunderbird-android"
},
"Firefox Focus": {
"Installation and updates": "installation-and-updates",
"Performance and connectivity": "performance-and-connectivity",
Expand Down
6 changes: 5 additions & 1 deletion playwright_tests/test_data/general_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"Firefox for iOS",
"Firefox for Enterprise",
"Thunderbird",
"Thunderbird for Android",
"Firefox Focus"
],
"premium_products": [
Expand Down Expand Up @@ -34,6 +35,7 @@
"Firefox Relay": "https://support.allizom.org/en-US/products/relay/technical",
"Pocket": "https://support.allizom.org/en-US/products/pocket/pocket-for-ios",
"Thunderbird": "https://support.allizom.org/en-US/products/thunderbird/settings",
"Thunderbird for Android": "https://support.allizom.org/en-US/products/thunderbird-android/settings",
"Firefox Focus": "https://support.allizom.org/en-US/products/focus-firefox/Focus-ios",
"Mozilla Account": "https://support.allizom.org/en-US/products/mozilla-account/passwords-recovery"
},
Expand All @@ -48,7 +50,8 @@
"MDN Plus": "https://support.allizom.org/en-US/products/mdn-plus",
"Firefox Focus": "https://support.allizom.org/en-US/products/focus-firefox",
"Firefox for Enterprise": "https://support.allizom.org/en-US/products/firefox-enterprise",
"Thunderbird": "https://support.allizom.org/en-US/products/thunderbird"
"Thunderbird": "https://support.allizom.org/en-US/products/thunderbird",
"Thunderbird for Android": "https://support.allizom.org/en-US/products/thunderbird-android"
},
"product_solutions": {
"Firefox": "https://support.allizom.org/en-US/questions/new/firefox",
Expand All @@ -61,6 +64,7 @@
"Firefox Relay": "https://support.allizom.org/en-US/questions/new/relay",
"Pocket": "https://support.allizom.org/en-US/questions/new/pocket",
"Thunderbird": "https://support.allizom.org/en-US/questions/new/thunderbird",
"Thunderbird for Android": "https://support.allizom.org/en-US/questions/new/thunderbird-android",
"Firefox Focus": "https://support.allizom.org/en-US/questions/new/focus-firefox",
"Mozilla Account": "https://support.allizom.org/en-US/questions/new/mozilla-account"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ def test_premium_products_aaq(page: Page):
is_premium=True
)
if utilities.get_page_url() == premium_form_link:
sumo_pages.aaq_form_page.click_aaq_form_submit_button()
sumo_pages.aaq_form_page.click_aaq_form_submit_button(with_force=True)

with allure.step("Verifying that the correct success message is displayed"):
assert sumo_pages.aaq_form_page.get_premium_card_submission_message(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,13 +301,12 @@ def test_unsupported_locales_fallback(page: Page):

# C2625000
@pytest.mark.kbArticleTranslation
def test_fallback_languages(self):
def test_fallback_languages(page: Page):
utilities = Utilities(page)
with allure.step("Verifying the language fallback"):
for key, value in FALLBACK_LANGUAGES.items():
self.navigate_to_link(HomepageMessages.STAGE_HOMEPAGE_URL + f"/{value}/")
expect(
self.page
).to_have_url(HomepageMessages.STAGE_HOMEPAGE_URL + f"/{key}/")
utilities.navigate_to_link(HomepageMessages.STAGE_HOMEPAGE_URL + f"/{value}/")
expect(page).to_have_url(HomepageMessages.STAGE_HOMEPAGE_URL + f"/{key}/")


# C2316347
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1156,11 +1156,7 @@ def test_edit_article_metadata_product_and_topic(page: Page):

with check, allure.step("Verifying that the correct breadcrumb is displayed"):
check.is_in(
"Pocket",
sumo_pages.kb_article_page.get_text_of_all_article_breadcrumbs()
)
check.is_in(
"Getting Started",
"Browse",
sumo_pages.kb_article_page.get_text_of_all_article_breadcrumbs()
)

Expand Down

0 comments on commit 33e0f6f

Please sign in to comment.