Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

140
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!