Advertisement
SeleniumETrainR

How to automate youtube using selenium Webdriver?

Dec 3rd, 2012
1,589
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. import org.openqa.selenium.firefox.FirefoxDriver;
  2.  
  3.  
  4. public class Youtube {
  5. public static void main(String[] args) throws InterruptedException {
  6. FirefoxDriver driver = new FirefoxDriver();
  7.  
  8. FlashObjectWebDriver flashApp = new FlashObjectWebDriver(driver, "movie_player");
  9. driver.manage().window().maximize();
  10. driver.get("http://tinyurl.com/bqnaoo7");
  11. Thread.sleep(2000L);
  12.  
  13. // let the video load
  14. while (Integer.parseInt(flashApp.callFlashObject("getPlayerState")) == 3){
  15. Thread.sleep(1000L);
  16. }
  17.  
  18. // Play the video for 10 seconds
  19. Thread.sleep(5000);
  20. flashApp.callFlashObject("pauseVideo");
  21. Thread.sleep(5000);
  22. flashApp.callFlashObject("playVideo");
  23. Thread.sleep(5000);
  24. flashApp.callFlashObject("seekTo","140","true");
  25. Thread.sleep(5000);
  26. flashApp.callFlashObject("mute");
  27. Thread.sleep(5000);
  28. flashApp.callFlashObject("setVolume","50");
  29. Thread.sleep(5000);
  30.  
  31.  
  32. }
  33.  
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement