in modules/page_object_newtab.py [0:0]
def check_layout(self) -> BasePage:
"""
Main method to check about:newtab layout is as expected
"""
self.element_exists("incontent-search-input")
logging.info("Search bar exists")
self.element_exists("recent-activity-section")
for i in range(1, self.REC_ARTICLE_TOTAL + 1):
document_height = self.driver.execute_script(
"return document.body.scrollHeight"
)
target_y = int(document_height) // i
# Sometimes we need to scroll around to force the article tile to load
# We're waiting until the article tiles load to resolve flake
for _ in range(2):
self.driver.execute_script(
"window.scrollTo(0, document.body.scrollHeight);"
)
self.driver.execute_script("window.scrollTo(0, 0);")
self.driver.execute_script(f"window.scrollTo(0, {target_y});")
self.get_element("loaded-image-by-index", labels=[str(i)])
assert len(self.get_recommended_articles()) == self.REC_ARTICLE_TOTAL
assert self.check_article_alignment()
assert self.count_sponsored_articles() > 0
assert self.check_popular_topics()
logging.info(f"Found {self.count_top_sites()} top sites")
# ODD: Sometimes we get 7 top sites, not 8
assert self.count_top_sites() in self.TOP_SITES_TOTAL