Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

146
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda