-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
three rex-web tests converted to playwright #2391
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
9f2d912
first rex-web tests converted to playwright
omehes 06db898
Update actions; add python playwright
TylerZeroMaster 3a1ae44
Move conftest into playwright
TylerZeroMaster 1be1742
Remove unused reference to selenium
TylerZeroMaster 0ff6a2c
Add requirements.txt
TylerZeroMaster cc124a8
removed testrail from requirements
omehes 3a8e931
stopping selenium qa tests from running
omehes 62a1517
Reorganising rex-web QA tests by removing osweb tests and adding rex …
omehes d17f9b8
added pypdf to requirements
omehes dc97a67
adjusting failing tests
omehes c1defee
correcting incorrect page object
omehes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Import fixtures | ||
pytest_plugins = "e2e.ui.fixtures.ui" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import requests | ||
|
||
import pytest | ||
import pytest_asyncio | ||
|
||
from playwright.async_api import async_playwright | ||
|
||
|
||
@pytest_asyncio.fixture | ||
async def chrome_page(): | ||
async with async_playwright() as playwright: | ||
browser_obj = playwright.chromium | ||
if browser_obj: | ||
ch_browser = await browser_obj.launch(headless=True, slow_mo=1200, timeout=120000) | ||
context = await ch_browser.new_context() | ||
page = await context.new_page() | ||
yield page | ||
|
||
await ch_browser.close() | ||
|
||
|
||
@pytest.fixture | ||
def abl_approved(): | ||
"""Return list of dictionaries of approved books in ABL json""" | ||
abl_url = "https://corgi.ce.openstax.org/api/abl/" | ||
abl_dict = requests.get(abl_url).json() | ||
return abl_dict | ||
|
||
|
||
@pytest.fixture | ||
def abl_uuids_slugs(): | ||
"""Returns dictionary of uuid:slug values of all collection entries in ABL api""" | ||
|
||
uuids_slugs = {} | ||
|
||
abl_url = "https://corgi.ce.openstax.org/api/abl/" | ||
abl_dict = requests.get(abl_url).json() | ||
|
||
for i in abl_dict: | ||
uuids_slugs[i["uuid"]] = i["slug"] | ||
|
||
return uuids_slugs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,285 @@ | ||
import asyncio | ||
import pytest | ||
|
||
from playwright.async_api import expect | ||
|
||
import re | ||
|
||
|
||
class HomeRex: | ||
def __init__(self, page): | ||
self.page = page | ||
|
||
# Subjects homepage | ||
|
||
@property | ||
def subjects_page_menu(self): | ||
return self.page.get_by_role("button", name="Subjects") | ||
|
||
@pytest.mark.asyncio | ||
async def click_subjects_page_menu(self): | ||
await self.subjects_page_menu.hover() | ||
|
||
@property | ||
def subjects_homepage_link(self): | ||
return self.page.get_by_role("link", name="All") | ||
|
||
@pytest.mark.asyncio | ||
async def click_subjects_homepage_link(self): | ||
await self.subjects_homepage_link.click() | ||
|
||
@property | ||
def language_selector_section(self): | ||
return self.page.locator("section.language-selector-section") | ||
|
||
@property | ||
def subjects_listing_section(self): | ||
return self.page.locator("section.subjects-listing") | ||
|
||
@property | ||
def about_openstax_section(self): | ||
return self.page.locator("section.about-openstax > div > h2") | ||
|
||
@property | ||
def learn_about_openstax_link(self): | ||
return self.page.locator("a").get_by_text("Learn about OpenStax") | ||
|
||
@pytest.mark.asyncio | ||
async def click_learn_about_openstax_link(self): | ||
await self.learn_about_openstax_link.click() | ||
|
||
@property | ||
def about_page(self): | ||
return self.page.locator("id=main") | ||
|
||
@property | ||
def book_toc_link(self): | ||
return self.page.locator("div.option.toc-option") | ||
|
||
@pytest.mark.asyncio | ||
async def click_book_toc_link(self): | ||
await self.book_toc_link.click() | ||
|
||
@property | ||
def book_toc_content(self): | ||
return self.page.locator("div.toc-slideout-contents > div > div") | ||
|
||
@property | ||
def book_toc_slideout_is_visible(self): | ||
return self.page.locator("div.toc-slideout-contents") | ||
|
||
@property | ||
def book_link(self): | ||
return self.page.locator("menu > li:nth-child(5) > a").get_by_text("Economics") | ||
|
||
@pytest.mark.asyncio | ||
async def click_book_link(self): | ||
await self.book_link.click() | ||
|
||
@property | ||
def book_cover_link(self): | ||
return self.page.locator("a").get_by_text("Principles of Macroeconomics 3e") | ||
|
||
@pytest.mark.asyncio | ||
async def click_book_cover_link(self): | ||
await self.book_cover_link.click() | ||
|
||
@property | ||
def view_online_link(self): | ||
return self.page.locator("a").get_by_text("View online") | ||
|
||
@pytest.mark.asyncio | ||
async def click_view_online_link(self): | ||
await self.view_online_link.click() | ||
|
||
@property | ||
def go_to_your_book_link(self): | ||
return self.page.locator("a.btn.go-to").get_by_text("Go to your ") | ||
|
||
@pytest.mark.asyncio | ||
async def click_go_to_your_book_link(self): | ||
await self.go_to_your_book_link.click() | ||
|
||
@property | ||
def highlights_option_is_visible(self): | ||
return self.page.locator("nudge-study-tools > button").get_by_text("Highlights") | ||
|
||
@property | ||
def order_a_print_copy_link_is_visible(self): | ||
return self.page.locator("div.BuyBook__BuyBook > a").get_by_text("Order a print copy") | ||
|
||
@property | ||
def citation_attribution_link_is_visible(self): | ||
return self.page.locator("div.ContentPane__Wrapper-sc-6et83r-0.hPmLNC > details > summary > " | ||
"span").get_by_text("Citation/Attribution") | ||
|
||
@property | ||
def giving_tuesday_popup_is_visible(self): | ||
return self.page.locator("div.text-side > h1").get_by_text("Embrace the spirit of Giving Tuesday today!") | ||
|
||
@property | ||
def giving_tuesday_popup_close_icon(self): | ||
return self.page.locator("button.put-away.no-title-bar") | ||
|
||
@pytest.mark.asyncio | ||
async def close_giving_tuesday_popup(self): | ||
await self.giving_tuesday_popup_close_icon.click() | ||
|
||
# Philanthropic support | ||
|
||
@property | ||
def philanthropic_support_section(self): | ||
return self.page.locator("section.philanthropic-support") | ||
|
||
@property | ||
def our_impact_link(self): | ||
return self.page.locator("a").get_by_text("Learn more about our impact") | ||
|
||
@pytest.mark.asyncio | ||
async def click_our_impact_link(self): | ||
await self.our_impact_link.click() | ||
|
||
@property | ||
def give_today_link_is_visible(self): | ||
return self.page.locator("#footer").get_by_role("link", name="Give today") | ||
|
||
@pytest.mark.asyncio | ||
async def click_give_today_link(self): | ||
await self.give_today_link_is_visible.click() | ||
|
||
# Subjects page footer section | ||
|
||
@property | ||
def footer_section(self): | ||
return self.page.locator("id=footer") | ||
|
||
@property | ||
def footer_section_help_is_visible(self): | ||
return self.page.locator("div.column.col1") | ||
|
||
@property | ||
def footer_section_openstax_is_visible(self): | ||
return self.page.locator("div.column.col2") | ||
|
||
@property | ||
def footer_section_policies_is_visible(self): | ||
return self.page.locator("div.column.col3") | ||
|
||
@property | ||
def footer_section_bottom_is_visible(self): | ||
return self.page.locator("div.bottom") | ||
|
||
@property | ||
@pytest.mark.asyncio | ||
async def footer_section_license_link(self): | ||
return await self.page.locator("div.copyrights").get_by_role("link").get_attribute("href") | ||
|
||
# Book page navigation | ||
|
||
@property | ||
def content_page_previous_next_page_bar_is_visible(self): | ||
return self.page.locator("div.PrevNextBar__BarWrapper-sc-13m2i12-3.fEZPiF") | ||
|
||
@property | ||
def content_page_previous_link_is_visible(self): | ||
return self.page.locator("a").get_by_text('Previous') | ||
|
||
@pytest.mark.asyncio | ||
async def click_content_page_previous_link(self): | ||
await self.content_page_previous_link_is_visible.click() | ||
|
||
@property | ||
def content_page_next_link_is_visible(self): | ||
return self.page.locator("a").get_by_text('Next') | ||
|
||
@pytest.mark.asyncio | ||
async def click_content_page_next_link(self): | ||
await self.content_page_next_link_is_visible.click() | ||
|
||
@property | ||
def content_page_black_overlay_is_visible(self): | ||
return self.page.locator("div.styles__NudgeContentWrapper-hrv0cf-" | ||
"1.fpMWRn").get_by_text("The study tools you need. 100% FREE! Highlight, take notes, " | ||
"and make your own study guides. It's all free.") | ||
|
||
@property | ||
def content_page_black_overlay_close(self): | ||
return self.page.locator("div.styles__NudgeWrapper-hrv0cf-0.fJZGzd > button") | ||
|
||
@pytest.mark.asyncio | ||
async def click_content_page_black_overlay_close(self): | ||
await self.content_page_black_overlay_close.click() | ||
|
||
@property | ||
def subject_listing_book_is_visible(self): | ||
return self.page.locator("a").get_by_text("Astronomy") | ||
|
||
@pytest.mark.asyncio | ||
async def click_subject_listing_book(self): | ||
await self.subject_listing_book_is_visible.click() | ||
|
||
@property | ||
def book_selection(self): | ||
return self.page.locator("div").get_by_text("Astronomy 2e") | ||
|
||
@pytest.mark.asyncio | ||
async def click_book_selection(self): | ||
await self.book_selection.click() | ||
|
||
@property | ||
def buy_print_copy_button_is_visible(self): | ||
return self.page.locator("a").get_by_text("Buy a print copy") | ||
|
||
@pytest.mark.asyncio | ||
async def click_buy_print_copy_button(self): | ||
await self.buy_print_copy_button_is_visible.click() | ||
|
||
@property | ||
def bookstore_box_is_visible(self): | ||
return self.page.locator("div").get_by_text("Bookstore") | ||
|
||
@property | ||
def order_options_button_is_visible(self): | ||
return self.page.locator("a").get_by_text("Order options") | ||
|
||
@pytest.mark.asyncio | ||
async def order_options_href(self): | ||
await self.page.locator("a").get_by_text("Order options").get_attribute('href') | ||
|
||
@pytest.mark.asyncio | ||
async def click_order_options_button(self): | ||
await self.order_options_button_is_visible.click() | ||
|
||
@property | ||
def highlight_recommended_popup_is_visible(self): | ||
return self.page.locator("span").get_by_text("Recommended") | ||
|
||
@property | ||
def cookies_accept_is_visible(self): | ||
return self.page.locator("div.osano-cm-dialog__buttons.osano-cm-buttons").get_by_text("Accept") | ||
|
||
@pytest.mark.asyncio | ||
async def click_cookies_accept(self): | ||
await self.cookies_accept_is_visible.click() | ||
|
||
@property | ||
def cookieyes_accept_is_visible(self): | ||
return self.page.locator("div.cky-notice-btn-wrapper > button.cky-btn.cky-btn-accept") | ||
|
||
@pytest.mark.asyncio | ||
async def click_cookieyes_accept(self): | ||
await self.cookieyes_accept_is_visible.click() | ||
|
||
@property | ||
def toc_is_visible(self): | ||
return self.page.locator("span").get_by_text("Table of contents") | ||
|
||
@property | ||
def bookbanner_is_visible(self): | ||
return self.page.locator("div.bookbanner") | ||
|
||
# Accessibility page (hidden link: go to accessibility page) | ||
|
||
@property | ||
def accessibility_help_content(self): | ||
return self.page.locator("#maincontent > div") |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting... there's another list at https://raw.githubusercontent.com/openstax/content-manager-approved-books/main/approved-book-list.json that Exercises uses