From 1d264b7e1a8909c3941f3084296265da82680942 Mon Sep 17 00:00:00 2001 From: Charlie DeTar Date: Mon, 14 Apr 2014 21:05:53 -0600 Subject: [PATCH] Refactor create-hoa test to avoid timing failures (#267) --- test/test.create-hoa.selenium.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/test/test.create-hoa.selenium.js b/test/test.create-hoa.selenium.js index bae02f12..d64dd29e 100644 --- a/test/test.create-hoa.selenium.js +++ b/test/test.create-hoa.selenium.js @@ -104,16 +104,15 @@ describe("CREATE HOA", function() { browser.switchTo().window(handles[0]); }); - browser.waitForSelector(".join-hoa"); - // Wait for the hangout broadcast video to be embedded. browser.waitForScript("$"); + browser.waitForSelector(".join-hoa"); var embedSrcScript = "return $('.video-player iframe').attr('src');"; - browser.executeScript(embedSrcScript).then(function(src) { - expect(src).to.not.be(null); - expect(src.indexOf("http://www.youtube.com/embed/" + - event.get("hoa").get("hangout-broadcast-id")) - ).to.be(0); + browser.wait(function() { + return browser.executeScript(embedSrcScript).then(function(src) { + return src && src.indexOf("http://www.youtube.com/embed/" + + event.get("hoa").get("hangout-broadcast-id")) === 0; + }); }); browser.executeScript("return $('.join-hoa').attr('href');").then(function(href) { expect(href).to.eql(event.get("hoa").getParticipationLink());