The main menu of this page ( linio ) contains 11 links. Interested in only 9 (with a gray background and the display of the submenu when it hangs).
I want to click every single item in a submenu of 9 options. Desired process:
1.-First section: "Celulares y Tablets".
2.-Go to: "Celulares y Smartphones". Click on this page. 3.-Extract some data (verified, I was able to do this).
4.-Go to the next submenu in "Celulares y Tablets". What is: "Accesorios Celular".
5.-Extract some data and go to the next submenu. After completing all the submenus in this section, I will move on to the next large section: "TV-Audio-y-Foto".
And so on with 9 sections.
HTML structure
After looking at the source code, I came to the following:
1. Main heading: the main heading is in the tag "nav":
<nav id="headerMainMenu>
2.- In the tag "nav" is "ul", and each "il" inside has an "id" for each of 9 sections:
<nav id="headerMainMenu> <ul> <il id = "category-item-celulares-y-tablets"><a href="..."></il> <il id = "category-item-celulares-y-tablets"><a href="..."></il> <il id = "category-item-celulares-y-tablets"><a href="..."></il> </ul> </nav>
3.- Inside the il elements there are div elements containing the links we need. Note the <a> with class = "subnav__title".
<nav id="headerMainMenu> <ul> <il id = "category-item-celulares-y-tablets"><a href="..."> <div class="col-3"> <a href="..."class="subnav__title">TV y Video</a> </il> <il id = "category-item-celulares-y-tablets"><a href="..."></il> <il id = "category-item-celulares-y-tablets"><a href="..."></il> </ul> </nav>
4.- Using RSelenium to go to each section:
library(RSelenium) library(rvest)
But this error is displayed:
> webElem$sendKeysToElement(list(key = "enter")) Error: Summary: StaleElementReference Detail: An element command failed because the referenced element is no longer attached to the DOM. class: org.openqa.selenium.StaleElementReferenceException
* I think this question may help. But I do not understand.
** I think my CSS is good.