in playwright_tests/pages/contribute/contribute_pages/contributor_discussions/forum_thread_page.py [0:0]
def __init__(self, page):
super().__init__(page)
self.utilities = Utilities(page)
# Locators related to the page breadcrumb.
self.breadcrumb_options = page.locator("ol#breadcrumbs li")
self.breadcrumb_links = page.locator("ol#breadcrumbs li a")
self.breadcrumb_link = lambda breadcrumb_name: page.locator(
"ol#breadcrumbs li").get_by_role("link", name=breadcrumb_name)
# Locators related to the Contributor Discussions side navbar.
self.contributor_discussions_side_navbar_header = page.locator(
"#for-contributors-sidebar ul li.sidebar-subheading")
self.contributor_discussions_side_navbar_items = page.locator(
"#for-contributors-sidebar ul li:not(.sidebar-subheading)")
self.contributor_discussions_side_navbar_item = lambda item_name: page.locator(
"#for-contributors-sidebar ul li:not(.sidebar-subheading)").get_by_role(
"link", name=item_name, exact=True)
# Locators related to the thread-actions section.
self.edit_thread_title_option = page.get_by_role("link", name="Edit Thread Title")
self.delete_this_thread_option = page.get_by_role("link", name="Delete this thread")
self.lock_this_thread_option = page.locator("//a[text()='Lock this thread']")
self.thread_locked_text = page.locator("p#thread-locked")
self.unlock_this_thread_option = page.locator("//a[text()='Unlock this thread']")
self.sticky_this_thread_option = page.locator("//a[text()='Sticky this thread']")
self.unsticky_this_thread_option = page.locator("//a[text()='Unsticky this thread']")
# Delete thread page.
self.delete_button = page.locator("input[value='Delete']")
# Locators related to the move thread section.
self.move_thread_dropdown = page.locator("select[name='forum']")
self.move_thread_button = page.locator("input[value='Move Thread']")
# Thread locators
self.forum_title = page.locator("p#forum-title")
self.thread_title = page.locator("h1.sumo-page-heading")
self.thread_posted_thread_title = page.locator("h1#sumo-page-heading")
self.thread_meta = page.locator("ul#thread-meta li")
self.watch_this_thread_button = page.locator("button#watch-thread-toggle")
self.post_author = lambda post_id: page.locator(
f"//li[@id='post-{post_id}']//span[@class='display-name']")
self.post_time = lambda post_id: page.locator(
f"//li[@id='post-{post_id}']//span[@class='asked-on']/time")
self.post_content = lambda post_id: page.locator(
f"//li[@id='post-{post_id}']//div[@class='content']/p")
self.thread_post = lambda post_id: page.locator(f"li#post-{post_id}")
self.thread_post_by_content = lambda post_content: page.locator(
f"//div[@class='content']/p[normalize-space(text())='{post_content}']")
self.modified_by = lambda post_id: page.locator(f"li#post-{post_id} p.text-body-sm")
self.quoted_thread_post_mention = lambda post_id: page.locator(
f"li#post-{post_id} div.content em")
self.quoted_thread_post_mention_link = lambda post_id: page.locator(
f"li#post-{post_id} div.content em a")
self.quoted_thread_post_quote = lambda post_id: page.locator(
f"li#post-{post_id} div.content blockquote")
# Thread post more options locators
self.post_3_dotted_menu = lambda post_id: page.locator(f"li#post-{post_id}").get_by_role(
"button", name="more options")
self.post_3_dotted_menu_expanded = lambda post_id: page.locator(
f"//li[@id='post-{post_id}']//ul[contains(@id,'expand-datahasdropdown')]")
self.private_message = lambda post_id: page.locator(
f"li#post-{post_id} li.mzp-c-menu-list-item").get_by_role(
"link", name="Private message")
self.post_edit_this_post = lambda post_id: page.locator(
f"li#post-{post_id} li.mzp-c-menu-list-item").get_by_role(
"link", name="Edit this post")
self.delete_this_post = lambda post_id: page.locator(
f"li#post-{post_id} li.mzp-c-menu-list-item").get_by_role(
"link", name="Delete this post")
self.quote_this_post = lambda post_id: page.locator(
f"li#post-{post_id} li.mzp-c-menu-list-item").get_by_role(
"link", name="Quote")
self.report_this_post = lambda post_id: page.locator(
f"li#post-{post_id} li.mzp-c-menu-list-item").get_by_role(
"link", name="Report Abuse")
self.link_this_post = lambda post_id: page.locator(
f"li#post-{post_id} li.mzp-c-menu-list-item").get_by_role(
"link", name="Link to this post")
# Post a reply locators
self.post_reply_textarea = page.locator("textarea#id_content")
self.preview_reply_button = page.locator("button#preview")
self.post_reply_button = page.get_by_role("button", name="Post Reply")