def test_right_arrows(page):
    page.goto("index.html")
    while(True):
        # Keeps going to the next page until there is no right arrow
        right_arrow = page.query_selector("//*[@id='relations-next']/a")
        if(right_arrow):
            page.click("//*[@id='relations-next']/a")
            page.wait_for_load_state()
        else:
            break

# TODO make a similar test but going from de last page
# to the previous one until it gets to the first one

def get_menu_titles(page) -> list:
    page.goto("index.html")
    page.wait_for_load_state()
    menu_list = page.query_selector_all("//*[@class='toctree-wrapper compound']/ul/li/a")

    menu_titles = []
    for i in menu_list:
        menu_item = i.as_element().inner_text()
        menu_titles.append(menu_item)

    return menu_titles


def test_check_titles(page):
    menu_list = get_menu_titles(page)
    page.goto("index.html")
    page.wait_for_load_state()

    for menu_item in menu_list:
        right_arrow = page.query_selector("//*[@id='relations-next']/a")
        if(right_arrow):
            page.click("//*[@id='relations-next']/a")
            page.wait_for_load_state()
            page_title = page.title()
            page_title = page_title.split(" — ")[0]
            assert page_title == menu_item
        else:
            break

Implement assertions and a for instead of a while loop
Implement assertions and a for instead of a while loop

- def test_right_arrows(page):
+ def get_menu_titles(page) -> list:
      page.goto("index.html")
-     while(True):
-         # Keeps going to the next page until there is no right arrow
+     page.wait_for_load_state()
+     menu_list = page.query_selector_all("//*[@class='toctree-wrapper compound']/ul/li/a")
+ 
+     menu_titles = []
+     for i in menu_list:
+         menu_item = i.as_element().inner_text()
+         menu_titles.append(menu_item)
+ 
+     return menu_titles
+ 
+ 
+ def test_check_titles(page):
+     menu_list = get_menu_titles(page)
+     page.goto("index.html")
+     page.wait_for_load_state()
+ 
+     for menu_item in menu_list:
          right_arrow = page.query_selector("//*[@id='relations-next']/a")
          if(right_arrow):
              page.click("//*[@id='relations-next']/a")
              page.wait_for_load_state()
+             page_title = page.title()
+             page_title = page_title.split(" — ")[0]
+             assert page_title == menu_item
          else:
              break
  
- # TODO make a similar test but going from de last page
- # to the previous one until it gets to the first one
- 
Implement assertions and a for instead of a while loop
## Code Before:
def test_right_arrows(page):
    page.goto("index.html")
    while(True):
        # Keeps going to the next page until there is no right arrow
        right_arrow = page.query_selector("//*[@id='relations-next']/a")
        if(right_arrow):
            page.click("//*[@id='relations-next']/a")
            page.wait_for_load_state()
        else:
            break

# TODO make a similar test but going from de last page
# to the previous one until it gets to the first one

## Instruction:
Implement assertions and a for instead of a while loop
## Code After:
def get_menu_titles(page) -> list:
    page.goto("index.html")
    page.wait_for_load_state()
    menu_list = page.query_selector_all("//*[@class='toctree-wrapper compound']/ul/li/a")

    menu_titles = []
    for i in menu_list:
        menu_item = i.as_element().inner_text()
        menu_titles.append(menu_item)

    return menu_titles


def test_check_titles(page):
    menu_list = get_menu_titles(page)
    page.goto("index.html")
    page.wait_for_load_state()

    for menu_item in menu_list:
        right_arrow = page.query_selector("//*[@id='relations-next']/a")
        if(right_arrow):
            page.click("//*[@id='relations-next']/a")
            page.wait_for_load_state()
            page_title = page.title()
            page_title = page_title.split(" — ")[0]
            assert page_title == menu_item
        else:
            break
