openvidu-test-e2e: print screenshot on event timeout

pull/331/head
pabloFuente 2019-09-27 12:03:15 +02:00
parent b2e3c7ac2b
commit 8fe65335ce
1 changed files with 6 additions and 0 deletions

View File

@ -17,6 +17,8 @@
package io.openvidu.test.e2e; package io.openvidu.test.e2e;
import static org.openqa.selenium.OutputType.BASE64;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
@ -34,6 +36,7 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Consumer; import java.util.function.Consumer;
import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement; import org.openqa.selenium.WebElement;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -164,6 +167,9 @@ public class OpenViduEventManager {
this.setCountDown(eventName, eventSignal); this.setCountDown(eventName, eventSignal);
try { try {
if (!eventSignal.await(secondsOfWait * 1000, TimeUnit.MILLISECONDS)) { if (!eventSignal.await(secondsOfWait * 1000, TimeUnit.MILLISECONDS)) {
String screenshot = "data:image/png;base64," + ((TakesScreenshot) driver).getScreenshotAs(BASE64);
System.out.println("TIMEOUT SCREENSHOT");
System.out.println(screenshot);
throw (new TimeoutException()); throw (new TimeoutException());
} }
} catch (InterruptedException | TimeoutException e) { } catch (InterruptedException | TimeoutException e) {