def click_see_more_links()

in pages/desktop/frontend/home.py [0:0]


    def click_see_more_links(self, count):
        link = [el for el in self.see_more_links_in_shelves]
        target = link[count].get_attribute("target")
        # external links are opened in new tabs, so we need to account for multiple windows
        if target == "_blank":
            home_tab = self.driver.current_window_handle
            link[count].click()
            self.wait.until(EC.number_of_windows_to_be(2))
            new_tab = self.driver.window_handles[1]
            self.driver.switch_to.window(new_tab)
            # see more external links can contain variable content we might not know in advance (especially on prod)
            # the solution used here is to verify that the content we link to is available (i.e. page response = 200)
            self.wait.until(custom_waits.url_not_contains("about:blank"))
            page = requests.head(self.driver.current_url)
            assert (
                page.status_code == 200
            ), f"The response status code was {page.status_code}"
            self.driver.close()
            self.driver.switch_to.window(home_tab)
        else:
            # similar to external links, internal links might contain unpredictable content;
            # in this case, we check that the content exists inside the AMO domain
            link[count].click()
            self.wait.until(
                EC.invisibility_of_element_located((By.CLASS_NAME, "LoadingText"))
            )
            assert "addons" in self.driver.current_url
            page = requests.head(self.driver.current_url)
            assert (
                page.status_code == 200
            ), f"The response status code was {page.status_code}"
            self.driver.back()
            # waits for the homepage to reload
            self.wait.until(
                EC.invisibility_of_element_located((By.CLASS_NAME, "LoadingText"))
            )