           fs.writeFileSync(sigmaFilePath, "doesn't matter")
           treeView.updateRoots()
 
-          omicronDir = $(treeView.roots[0].entries).find(".directory:contains(omicron):first span")[0]
-          expect(omicronDir.title).toEqual("omicron")
+          omicronDir = findDirectoryContainingText(treeView.roots[0], "omicron")
+          expect(omicronDir.header.textContent).toEqual("omicron")
           omicronDir.dispatchEvent(new MouseEvent('click', {bubbles: true, detail: 1}))
-          piDir = $(treeView.roots[0].entries).find(".directory:contains(omicron) .entries .directory:contains(pi) span")[0]
-          expect(piDir.title).toEqual("pi")
-          sigmaFile = $(treeView.roots[0].entries).find(".directory:contains(omicron) .entries .file:contains(sigma) span")[0]
-          expect(sigmaFile.title).toEqual("sigma.txt")
+          piDir = findDirectoryContainingText(omicronDir, "pi")
+          expect(piDir.header.textContent).toEqual("pi")
+          sigmaFile = findFileContainingText(omicronDir, "sigma.txt")
+          expect(sigmaFile.fileName.textContent).toEqual("sigma.txt")
 
       describe "when a directory is created within a directory with another squashed directory", ->
         it "un-squashes the directories", ->
           jasmine.attachToDOM(workspaceElement)
-          piDir = $(treeView.roots[0].entries).find(".directory:contains(omicron#{path.sep}pi):first")[0]
+          piDir = findDirectoryContainingText(treeView.roots[0], "omicron#{path.sep}pi")
           expect(piDir).not.toBeNull()
           # omicron is a squashed dir, so searching for omicron would give us omicron/pi instead
           omicronPath = piDir.getPath().replace "#{path.sep}pi", ""

      it "squashes three dir names when the first and second only contain single dirs", ->
        if path.sep is '\\'
          # First escape the backslashes for Coffeescript, then escape them for jQuery
          epsilonDir = $(treeView.roots[0].entries).find(".directory:contains(gamma\\\\delta\\\\epsilon):first")
        else
          epsilonDir = $(treeView.roots[0].entries).find(".directory:contains(gamma#{path.sep}delta#{path.sep}epsilon):first")
        epsilonDir[0].expand()
        epsilonEntries = [].slice.call(epsilonDir[0].children[1].children).map (element) ->
          element.innerText

        expect(epsilonEntries).toEqual(["theta.txt"])

      it "does not squash a dir name when there are two child dirs ", ->
        lambdaDir = $(treeView.roots[0].entries).find('.directory:contains(lambda):first')
        lambdaDir[0].expand()
        lambdaEntries = [].slice.call(lambdaDir[0].children[1].children).map (element) ->
          element.innerText

        expect(lambdaEntries).toEqual(["iota", "kappa"])


        rootDirPath = treeView.roots[0].getPath()
        expect(rootDirPath).toBe(rootDir)
        zetaDirPath = findDirectoryContainingText(treeView.roots[0], 'zeta').getPath()
        expect(zetaDirPath).toBe(zetaDir)

      it "does not squash a file in to a DirectoryViews", ->
        zetaDir = findDirectoryContainingText(treeView.roots[0], 'zeta')
        zetaDir.expand()
        zetaEntries = [].slice.call(zetaDir.children[1].children).map (element) ->
          element.innerText

        expect(zetaEntries).toEqual(["zeta.txt"])
