2

I'm having hard times making videos play with the following stack: Selenium + BrowserStack + Android + JavascriptExecutor + VideoJS Player/JWPlayer. Let's take VideosJS player as an example.

Please note, that's not Appium.

  • When I click the "Play Video" button with Selenium (playBackButton.click();) - it starts the playback. Both on desktop and mobile
  • When I click with Javascript (executor.executeScript("arguments[0].click();", playBackButton);) - it doesn't start the playback on mobile. Works fine on desktop.
  • When I try to execute the native method .play() - it doesn't work on mobile, works fine on desktop.

What gives?

Additional details (not sure they're needed, but still)

String xpath = "//*[@title='Play Video']";
playBackButton = _webDriver.findElement(By.xpath(xpath));
String script = "function sleep(ms) {" +
                "return new Promise(resolve => setTimeout(resolve, ms)); }" +
                "async function demo() {" +
                "await sleep(5000);" +
                "try{" +
                "jwplayer().play();}" +
                "catch(err) {" +
                "console.log('error');}" +
                "try{" +
                "var videoId = document.getElementsByTagName('video')[0].getAttribute('id');" +
                "videojs(videoId).play();}" +
                "catch(err){" +
                "console.log('error');}}" +
                "demo();";
JavascriptExecutor executor = (JavascriptExecutor) _webDriver;
//executor.executeScript("arguments[0].click();", playBackButton);
//executor.executeScript(script);
//playBackButton.click();
Nick Slavsky
  • 1,300
  • 3
  • 19
  • 39

0 Answers0