11

I have a FuncUnit test case wherein I open a webpage using

F.open("http://www.example.com");

There is a known issue in our page that approximately one in around 20 times the webpage would not load for whatever reason. I want to retry when it does not load. But in FuncUnit there is no way to suppress error if it fails to load the page. Is there a way to suppress error message in Funcunit?

Sathish
  • 409
  • 8
  • 24
  • I'm surprised you can open a remote URL at all. I just tried `F.open('https://www.google.com')` and get an error. I don't think `F.open()` is intended for remote URLs as you can't interact with the DOM anyways. What is it you are testing exactly? – Ryan Wheale Dec 21 '16 at 19:06
  • @Ryan It's actually not remote url. It's a localhost url. I just gave example.com as an example. – Sathish Dec 21 '16 at 21:37
  • Ah, ok. It appears like you found a solution, though hacky. Would you be able to provide a minimal set of files to reproduce this issue? This sounds like a bug that needs to get fixed. – Ryan Wheale Dec 21 '16 at 21:57

2 Answers2

1

Couldn't something like this work for you?

module("test", {
  setup: function() {
    let startMeUp = () => F.open('http://www.example.com'); // unfortunately doesn't return a usable value
    let checkCondition = () => {
      // grab F(F.window), and check for a known element in the page
      return elementFound;
    };
    while(!checkCondition()) {
      // element wasn't found, so let's try it again
      startMeUp();
      // maybe set a wait here
    }
  }
});
manonthemat
  • 6,101
  • 1
  • 24
  • 49
0
var url = "http://www.example.com"
F.get(url, function(data){
    console.log("Made an ajax call to make sure that F.open is always second call");
})
// Wait for few seconds before making the actual F.open
F.wait(5000,function(){
   F.open(url);
})

Whenever F.open fails ( i.e during one out of 20 times) I noticed that the second test point that uses F.open passes.However I cannot do F.open again in case the first one does not work as there is no way to suppress F.open error when the page does not load.

So I always make a simple ajax call before making the actual F.open. This is not the right way to do it but it works for us as we don't actually care whether the page is a first/second time load in our tests.

Sathish
  • 409
  • 8
  • 24