diff --git a/spec/requests/top_panel_spec.rb b/spec/requests/top_panel_spec.rb
index d1cea6d86d2e6ccc86e6689dd9f468cf377a1731..a5b5a2c9b35a2dcd37e11d9acd9eb7de6d3cad91 100644
--- a/spec/requests/top_panel_spec.rb
+++ b/spec/requests/top_panel_spec.rb
@@ -7,8 +7,9 @@ describe "Top Panel", :js => true do
     before do
       visit projects_path
       fill_in "search", :with => "Ke"
-      sleep(2)
-      find(:xpath, "//ul[contains(@class,'ui-autocomplete')]/li/a[.=\"Keys\"]").click
+      within ".ui-autocomplete" do 
+        find(:xpath, "//a[.=\"Keys\"]").click
+      end
     end
 
     it "should be on projects page" do
@@ -23,8 +24,9 @@ describe "Top Panel", :js => true do
       visit project_path(@project)
 
       fill_in "search", :with => "Commi"
-      sleep(2)
-      find(:xpath, "//ul[contains(@class,'ui-autocomplete')]/li/a[.=\"#{@project.code} / Commits\"]").click
+      within ".ui-autocomplete" do 
+        find(:xpath, "//a[.=\"#{@project.code} / Commits\"]").click
+      end
     end
 
     it "should be on projects page" do