سؤال

When I try to use FuncUnit to open a browser window to run some tests, the window it opens is too narrow and the site I am testing hides some menu items to work with the narrow window. Is there some way to increase the width of the window FuncUnit opens so the presence of these menu items can be tested? The docs provide no help with this issue.

The FuncUnit code I have is really basic:

test("dummy test", function () {
F.open('http://localhost:8000/');
});

I can increase the size of the window by hand after the test starts running, but that does not work for automated testing.

EDIT:

  • I dug through the FuncUnit source code and found that it is setting the popup window width to half the browser width. Changing this fixed the issue.

Other attempts that worked less well:

  • I was able to test the page in an iframe, which resolves the width issue. All the F('#something') calls then require an extra parameter, so F('#something', 0). Every. Damn. Time.
  • Attempted to disable Bootstrap's responsive features. It requires extensive changes, but they are detailed here
  • Found a plugin for Chrome that forces popups into a new tab, fixing the width issue. It is called The One. The test is not able to communicate with the new tab.
هل كانت مفيدة؟

المحلول

In the callback of F.open() use F.win.resizeTo(width, height):

F.open("desired-url", function onOpenSuccess() {
    F.win.resizeTo(1024, 768);
});

نصائح أخرى

Looking at the FuncUnit API and code for F.Open() the answer appears to be no.

The F.open() method signature is defined as: open(path, success, timeout)

With no option to manually set the height, width. Looking at their source they are doing their own internal calcs for height, width.

FuncUnit F.open

What you could do is get their git project and extend the F.open() method to accept a height, width param. Or just use JQuery. FuncUnit appears to be targeted at unit testing so UI finesse might be a secondary objective for that project.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top