From eee34a757b804dff74c018a8841d4d9b8160094f Mon Sep 17 00:00:00 2001
From: srosse <none@none>
Date: Mon, 9 May 2016 19:46:13 +0200
Subject: [PATCH] OO-1593: finish the selenium test

---
 .../java/org/olat/selenium/ImsQTI21Test.java  |  3 ++-
 .../org/olat/selenium/page/qti/QTI21Page.java | 19 +++++++++++++++++--
 2 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/src/test/java/org/olat/selenium/ImsQTI21Test.java b/src/test/java/org/olat/selenium/ImsQTI21Test.java
index e226b57bce4..2ee08128c8c 100644
--- a/src/test/java/org/olat/selenium/ImsQTI21Test.java
+++ b/src/test/java/org/olat/selenium/ImsQTI21Test.java
@@ -128,7 +128,8 @@ public class ImsQTI21Test {
 			.answerSingleChoice(1)
 			.saveAnswer()
 			.endTest()
-			.closeTest();
+			.closeTest()
+			.assertOnAttempts(1);
 		
 		
 	}
diff --git a/src/test/java/org/olat/selenium/page/qti/QTI21Page.java b/src/test/java/org/olat/selenium/page/qti/QTI21Page.java
index fe9f6d707d8..060a03139f0 100644
--- a/src/test/java/org/olat/selenium/page/qti/QTI21Page.java
+++ b/src/test/java/org/olat/selenium/page/qti/QTI21Page.java
@@ -83,6 +83,16 @@ public class QTI21Page {
 		WebElement startButton = browser.findElement(startBy);
 		startButton.click();
 		OOGraphene.waitBusy(browser);
+		By mainBy = By.cssSelector("div.qtiworks.o_assessmenttest");
+		OOGraphene.waitElement(mainBy, 5, browser);
+		return this;
+	}
+	
+	public QTI21Page assertOnAttempts(int numOfAttemtps) {
+		By attemptBy = By.xpath("//div[contains(@class,'o_course_run')]//table//tr[contains(@class,'o_attempts')]//td[text()[contains(.,'" + numOfAttemtps + "')]]");
+		OOGraphene.waitElement(attemptBy, 5, browser);
+		WebElement attemptEl = browser.findElement(attemptBy);
+		Assert.assertTrue(attemptEl.isDisplayed());
 		return this;
 	}
 	
@@ -109,7 +119,7 @@ public class QTI21Page {
 
 	//TODO still QTI 1.2
 	public QTI21Page answerMultipleChoice(int... selectPositions) {
-		By itemsBy = By.cssSelector("div.o_qti_item_choice_option input[type='checkbox']");
+		By itemsBy = By.cssSelector("div.choiceInteraction input[type='checkbox']");
 		List<WebElement> optionList = browser.findElements(itemsBy);
 		for(int selectPosition:selectPositions) {
 			Assert.assertTrue(optionList.size() > selectPosition);
@@ -167,7 +177,12 @@ public class QTI21Page {
 		By endBy = By.cssSelector("a.o_sel_close_test");
 		browser.findElement(endBy).click();
 		OOGraphene.waitBusy(browser);
-		//TODO qti confirm
+		
+		// confirm
+		By confirmButtonBy = By.cssSelector("div.modal-dialog div.modal-footer a");
+		List<WebElement> buttonsEl = browser.findElements(confirmButtonBy);
+		buttonsEl.get(0).click();
+		OOGraphene.waitBusy(browser);
 		return this;
 	}
 }
-- 
GitLab