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

141
Vistas
Fix Selenium JS issue with video players

Hello I'm writing some selenium web scraping code and I want to handle a video player to stop and to play. Basically I handle the player using JS DOM (.play() and .pause()). The problem is that I'm having an issue scraping multiple videos, like: I scrape and handle a video from url1 and when I go to url2, the video wouldn't be handled

const myFunc = async (driver) => {
    await driver.executeScript('document.getElementsByTagName("video")[0].start()')
    await driver.executeScript(`document.getElementsByTagName("video")[0].currentTime = ${opening}`)
    const actions = driver.actions()
    await actions.move(driver.findElement(By.tagName('video'))).sendKeys('f').perform()
    const checkEnding = async () => {
        setTimeout(async () => {
            const currentTime = await driver.executeScript('return document.getElementsByTagName("video")[0].currentTime')
            const btns = await driver.findElements(By.xpath('/html/body/center/div[2]/footer/div[1]/div'))
            const btnNext = btns[btns.length - 1]
            console.log(SERVICE + (await btnNext.getAttribute('onclick')).replace("window.location.href='",''))
            console.log(currentTime)
            if (currentTime >= ending) {
                driver.get(SERVICE + (await btnNext.getAttribute('onclick')).replace("window.location.href='",''))
                myFunc(driver)
            } else checkEnding()
        }, 2E3)
    }
    checkEnding()
}

I debugged very much this code and I tried also to play it by action click but nothing happens, I also tried to run a test script and it works as well.

about 4 years ago · Juan Pablo Isaza
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