diff --git a/src/test/java/org/olat/util/CatalogTreeEntryPosition.vm b/src/test/java/org/olat/util/CatalogTreeEntryPosition.vm
new file mode 100644
index 0000000000000000000000000000000000000000..80b524827e9a9cb05e509da699117fe2a104200f
--- /dev/null
+++ b/src/test/java/org/olat/util/CatalogTreeEntryPosition.vm
@@ -0,0 +1,32 @@
+offset = -1;
+
+if(document.querySelector){
+    var selector = "${treeSelector}";
+    var path = "${treePath}";
+    
+    /* make array out of path */
+    path = path.substring(1);
+    var item = path.split("/");
+
+    /* count items till path fits */
+    var selection = window.document.evaluate(selector, window.document.body, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
+    var i = 0;
+    var j = 0;
+    
+    for(; i < selection.snapshotLength && j < item.length; i++){
+        var current = selection.snapshotItem(i);
+        
+        if(current != null){
+        	var itemSelector = "(" + selector + ")[" + (i) + "]//div[contains(@class, 'b_selectiontree_content') and text()='" + item[j] + "']";
+        	var itemSelection = window.document.evaluate(itemSelector, window.document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
+        
+        	if(itemSelection != null && itemSelection.snapshotLength > 0){
+        		j++;
+        	}
+        }
+    }
+    
+    offset = (i / 2) - (item.length - 1);
+}
+
+offset;
diff --git a/src/test/java/org/olat/util/FunctionalCourseUtil.java b/src/test/java/org/olat/util/FunctionalCourseUtil.java
index f4773ae0fc6048fef2880374b07318826da6f2bc..1f6badde2cbf4c339fb7683913599114016196f4 100644
--- a/src/test/java/org/olat/util/FunctionalCourseUtil.java
+++ b/src/test/java/org/olat/util/FunctionalCourseUtil.java
@@ -24,6 +24,7 @@ import java.io.StringWriter;
 import java.net.MalformedURLException;
 import java.net.URI;
 import java.util.ArrayList;
+import java.util.List;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
@@ -887,38 +888,42 @@ public class FunctionalCourseUtil {
 		/*
 		 * Determine best matching item by using regular expressions
 		 */
-		Matcher categoryMatcher = categoryPattern.matcher(path);
-		
 		StringBuffer itemLocator = new StringBuffer();
-		int i = 0;
-		
-		while(categoryMatcher.find()){
-			itemLocator.append("(<div[\\s]*class=\"b_selectiontree_content\"[\\s]*>[\\s]*" + categoryMatcher.group(1) + "[\\s]*</div>[\\s]*)?[\\s]*");
-			i++;
-		}
-	
-		itemLocator.deleteCharAt(itemLocator.length() - 1);
-		int segmentCount = i;
-		String item = path.substring(path.lastIndexOf('/') + 1);
+		itemLocator.append("//div[contains(@class, 'b_selectiontree_item')]");
 		
-		Pattern itemPattern = Pattern.compile(itemLocator.toString());
-		String dom = browser.getHtmlSource();
-		Matcher itemMatcher = itemPattern.matcher(dom);
+		VelocityContext context = new VelocityContext();
+
+		context.put("treeSelector", itemLocator.toString());
+		context.put("treePath", path);
 		
-		int offset = 1;
-		boolean foundPath = false;
+		VelocityEngine engine = null;
+
+		engine = new VelocityEngine();
+
+		StringWriter sw = new StringWriter();
+		Integer offset = null;
 		
-		for(; itemMatcher.find(); offset++){
-			int j = 1;
+		try {
+			engine.evaluate(context, sw, "catalogTreeEntryPosition", FunctionalEPortfolioUtil.class.getResourceAsStream("CatalogTreeEntryPosition.vm"));
+
+			offset = new Integer(browser.getEval(sw.toString()));
 			
-			if(itemMatcher.group(0) != null && !itemMatcher.group(0).isEmpty()){
-				foundPath = true;
-				break;
+			if(offset.intValue() == -1){
+				return(null);
 			}
-		}
-		
-		if(!foundPath){
-			return(null);
+
+		} catch (ParseErrorException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		} catch (MethodInvocationException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		} catch (ResourceNotFoundException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		} catch (IOException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
 		}
 		
 		/* create selector */
@@ -926,10 +931,8 @@ public class FunctionalCourseUtil {
 				
 		selectorBuffer.append("xpath=(//div[contains(@class, '")
 		.append("b_selectiontree_item")
-		.append("')]//div[contains(@class, 'b_selectiontree_content') and text()='")
-		.append(item)
-		.append("']/../..//input[@type='radio'])[position()='")
-		.append(offset)
+		.append("')]//input[@type='radio'])[position()='")
+		.append(offset.intValue())
 		.append("']");
 		
 		return(selectorBuffer.toString());