javascript - Using Selenium Webdriver (with Java) to test a video without ID -
i trying test video (its in webm format) doesn't have id using standard actions pause/play/play beginning. here found far http://roadtoautomation.blogspot.com.au/2014/04/road-to-automate-html5-video-with.html
so paste here part of code:
javascriptexecutor js = (javascriptexecutor) driver; //play video js.executescript("document.getelementbyid(\"video\").play()"); thread.sleep(5000); //pause playing video js.executescript("document.getelementbyid(\"video\").pause()"); //check video paused system.out.println(js .executescript("document.getelementbyid(\"video\").paused")); unfortunately can't use method video doesn't have id. tried similar using document.getelementsbytagname, didn't work (go error document.getelementsbytagname(...).play not function). suggestions?
you don't have use javascript executor find video element.
find selenium , pass executor control it.
for example, if find by tag name:
webelement video = driver.findelement(by.tagname("video")); javascriptexecutor js = (javascriptexecutor) driver; js.executescript("arguments[0].play();", video);
Comments
Post a Comment