Back

Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in Selenium by (7k points)
edited by

I am trying to play the video by using JUnit.  After playing the video I need to take a screen shot. I am able to close this video window but not able to play/pause this video.

To close the video I have used code

 WebDriverWait wait = new WebDriverWait(driver, 20); wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(xPath))).click(); 

Please help me.

1 Answer

0 votes
by (31.9k points)

You can use the following code:

WebDriver driver=new FirefoxDriver();

driver.get("https://www.wonderplugin.com/wordpress-lightbox");

WebElement element=driver.findElement(By.xpath("//a[contains(text(),'Open a Div in Lightbox')]"));

element.click();

WebElement frameElement=driver.findElement(By.xpath("//iframe[@src='https://www.youtube.com/embed/wswxQ3mhwqQ']"));

        driver.switchTo().frame(frameElement);

        driver.findElement(By.xpath("//button[@aria-label=\'Play\']")).click();

Want to learn Selenium, checkout our Selenium training. 

Browse Categories

...