Skip to content
Snippets Groups Projects
Commit f08695c8 authored by srosse's avatar srosse
Browse files

no-jira: investigate issue with LTI selenium

parent 91121ee6
No related branches found
No related tags found
No related merge requests found
......@@ -45,19 +45,23 @@ public class LTIPage {
}
public LTIPage start() {
By startBy = By.xpath("//div[contains(@class,'o_button_group')]/a[contains(@onclick,'start')]");
OOGraphene.waitElement(startBy, browser);
browser.findElement(startBy).click();
By iframeBy = By.cssSelector(".o_iframedisplay iframe");
OOGraphene.waitElement(iframeBy, browser);
List<WebElement> iframes = browser.findElements(iframeBy);
browser = browser.switchTo().frame(iframes.get(0));
By launchedBy = By.xpath("//p[contains(text(),'Launch Validated.')]");
OOGraphene.waitElement(launchedBy, browser);
try {
By startBy = By.xpath("//div[contains(@class,'o_button_group')]/a[contains(@onclick,'start')]");
OOGraphene.waitElement(startBy, browser);
browser.findElement(startBy).click();
By iframeBy = By.cssSelector(".o_iframedisplay iframe");
OOGraphene.waitElement(iframeBy, browser);
WebElement iframe = browser.findElement(iframeBy);
WebDriver iframeBrowser = browser.switchTo().frame(iframe);
By launchedBy = By.xpath("//p[contains(text(),'Launch Validated.')]");
OOGraphene.waitElement(launchedBy, iframeBrowser);
} catch (Exception e) {
OOGraphene.takeScreenshot("LTIPage::start", browser);
throw e;
}
return this;
}
......
......@@ -21,6 +21,7 @@ package org.olat.selenium.page.graphene;
import java.io.File;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.time.Duration;
import java.util.Calendar;
import java.util.Date;
......@@ -31,11 +32,13 @@ import java.util.function.Predicate;
import org.apache.logging.log4j.Logger;
import org.junit.Assert;
import org.olat.core.logging.Tracing;
import org.olat.core.util.FileUtils;
import org.olat.core.util.StringHelper;
import org.openqa.selenium.By;
import org.openqa.selenium.ElementNotVisibleException;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.StaleElementReferenceException;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.TimeoutException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
......@@ -746,4 +749,20 @@ public class OOGraphene {
//e.printStackTrace();
}
}
public static void takeScreenshot(String test, WebDriver browser) {
TakesScreenshot scrShot = ((TakesScreenshot)browser);
File screenFile = scrShot.getScreenshotAs(org.openqa.selenium.OutputType.FILE);
SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd'T'HHmmss");
String filename = test + "" + format.format(new Date()) + ".jpg";
File path = new File("screenshots");
if(!path.exists() && !path.mkdirs()) {
path = new File(System.getProperty("java.io.tmpdir"), "screenshots");
path.mkdirs();
}
File screenshotFile = new File(path, filename);
log.error("Write screenshot: {} {}", test, screenshotFile);
FileUtils.copyFileToFile(screenFile, screenshotFile, true);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment