Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

401
Vistas
Scrolling element into view using javascrpit in RSelenium

I have following page

https://en.wikipedia.org/wiki/R_(programming_language)

I want to scroll until Milestones heading so that it is visible in browser,

My code,

library(RSelenium)
driver = rsDriver(browser = c("firefox"))

remDr <- driver[["client"]]

url = 'https://en.wikipedia.org/wiki/R_(programming_language)'
remDr$navigate(url)

I know that,

webElem <- remDr$findElement("css", "html")
webElem$sendKeysToElement(list(key="end"))

and

remDr$executeScript("window.scrollTo(0,document.body.scrollHeight);")

gets me to the end of page.

about 4 years ago · Santiago Gelvez
1 Respuestas
Responde la pregunta

0

We can scroll using java script to get the element (Milestone) into view by,

#navigate to webpage
url = 'https://en.wikipedia.org/wiki/R_(programming_language)'
remDr$navigate(url)

Identify the element,

ele = remDr$findElement(using = "xpath",'//*[@id="Milestones"]')
#scroll into view
remDr$executeScript("arguments[0].scrollIntoView(true);", list(ele))

enter image description here

Additional info,

To scroll to the middle of the page we can use,

remDr$executeScript("window.scrollTo(0,document.body.scrollHeight/2);")
about 4 years ago · Santiago Gelvez Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda