Page Layout Testing using LayoutTest
On this page we check whether a page, opened using BrowserTest, meets the look and feel criteria described in a 'spec file'.
This is done by using LayoutTest (so not by BrowserTest itself) which enables the use of the Galen Framework.
A 'spec file' is a file containing a specification, written in Galen Spec Language, which allows the location of objects relatively to each other on a page to be checked.
This file is loaded from the wiki's files section[?].
Since two different fixtures are used this test page uses two separate script tables: one to open the right page, and another to perform the layout check.
Depending on the focus of the test script one could consider whether it makes sense to use either BrowserTest (when the focus is no layout checking) or LayoutTest (when the focus of the script is browser actions) as a library[?]. This removes the need to explicitly switch between the two fixtures.
One can then just have a single script (using methods from both fixtures) manipuating the browser and checking the resulting pages' layout.
The configuration of Selenium (i.e. which browser to use) and starting the browser session is done in the SuiteSetup[?]. Which allows this configuration to be shared between tests. Closing the browser is done in SuiteTearDown, which happens after all tests are completed.
We start by opening the page to be checked.
script | browser test org.openqa.selenium.TimeoutException: timeout: Timed out receiving message from renderer: -0.004 (Session info: chrome=80.0.3987.87) (Driver info: chromedriver=80.0.3987.16 (320f6526c1632ad4f205ebce69b99a062ed78647-refs/branch-heads/3987@{#185}),platform=Windows NT 10.0.10586 x86_64) (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 0 milliseconds Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03' System info: host: 'localhost', ip: '127.0.0.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.15.0-1055-gcp', java.version: '1.8.0_242' Driver info: org.openqa.selenium.remote.RemoteWebDriver Capabilities {acceptInsecureCerts: false, acceptSslCerts: false, applicationCacheEnabled: false, browserConnectionEnabled: false, browserName: chrome, chrome: {chromedriverVersion: 80.0.3987.16 (320f6526c1632..., userDataDir: C:\Users\ADMINI~1\AppData\L...}, cssSelectorsEnabled: true, databaseEnabled: false, goog:chromeOptions: {debuggerAddress: localhost:49760}, handlesAlerts: true, hasMetadata: true, hasTouchScreen: false, javascriptEnabled: true, locationContextEnabled: true, mobileEmulationEnabled: false, nativeEvents: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: WINDOWS, platformName: WINDOWS, proxy: Proxy(), rotatable: false, setWindowRect: true, strictFileInteractability: false, takesHeapSnapshot: true, takesScreenshot: true, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unexpectedAlertBehaviour: ignore, unhandledPromptBehavior: ignore, version: 80.0.3987.87, webStorageEnabled: true, webdriver.remote.sessionid: 74ed0e4e6eb242638abd370a507...} Session ID: 74ed0e4e6eb242638abd370a507c4669 |
open org.openqa.selenium.TimeoutException: timeout: Timed out receiving message from renderer: -0.002 (Session info: chrome=80.0.3987.87) (Driver info: chromedriver=80.0.3987.16 (320f6526c1632ad4f205ebce69b99a062ed78647-refs/branch-heads/3987@{#185}),platform=Windows NT 10.0.10586 x86_64) (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 0 milliseconds Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03' System info: host: 'localhost', ip: '127.0.0.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.15.0-1055-gcp', java.version: '1.8.0_242' Driver info: org.openqa.selenium.remote.RemoteWebDriver Capabilities {acceptInsecureCerts: false, acceptSslCerts: false, applicationCacheEnabled: false, browserConnectionEnabled: false, browserName: chrome, chrome: {chromedriverVersion: 80.0.3987.16 (320f6526c1632..., userDataDir: C:\Users\ADMINI~1\AppData\L...}, cssSelectorsEnabled: true, databaseEnabled: false, goog:chromeOptions: {debuggerAddress: localhost:49760}, handlesAlerts: true, hasMetadata: true, hasTouchScreen: false, javascriptEnabled: true, locationContextEnabled: true, mobileEmulationEnabled: false, nativeEvents: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: WINDOWS, platformName: WINDOWS, proxy: Proxy(), rotatable: false, setWindowRect: true, strictFileInteractability: false, takesHeapSnapshot: true, takesScreenshot: true, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unexpectedAlertBehaviour: ignore, unhandledPromptBehavior: ignore, version: 80.0.3987.87, webStorageEnabled: true, webdriver.remote.sessionid: 74ed0e4e6eb242638abd370a507...} Session ID: 74ed0e4e6eb242638abd370a507c4669 at sun.reflect.GeneratedConstructorAccessor15.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:214) at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166) at org.openqa.selenium.remote.http.JsonHttpResponseCodec.reconstructValue(JsonHttpResponseCodec.java:40) at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:80) at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:44) at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552) at org.openqa.selenium.remote.RemoteWebDriver$RemoteTargetLocator.defaultContent(RemoteWebDriver.java:922) at nl.hsac.fitnesse.fixture.util.selenium.SeleniumHelper.switchToDefaultContent(SeleniumHelper.java:1197) at nl.hsac.fitnesse.fixture.slim.web.BrowserTest.switchToDefaultContent(BrowserTest.java:452) at nl.hsac.fitnesse.fixture.slim.web.BrowserTest.open(BrowserTest.java:235) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at fitnesse.slim.fixtureInteraction.SimpleInteraction.methodInvoke(SimpleInteraction.java:322) at nl.hsac.fitnesse.fixture.slim.SlimFixture.invoke(SlimFixture.java:61) at nl.hsac.fitnesse.fixture.slim.web.BrowserTest.superInvoke(BrowserTest.java:145) at nl.hsac.fitnesse.fixture.slim.web.BrowserTest.invoke(BrowserTest.java:92) at nl.hsac.fitnesse.fixture.slim.SlimFixture.aroundSlimInvoke(SlimFixture.java:41) at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at fitnesse.slim.fixtureInteraction.SimpleInteraction.methodInvoke(SimpleInteraction.java:322) at fitnesse.slim.fixtureInteraction.SimpleInteraction.callMethod(SimpleInteraction.java:305) at fitnesse.slim.fixtureInteraction.SimpleInteraction.invokeMethod(SimpleInteraction.java:290) at fitnesse.slim.fixtureInteraction.SimpleInteraction.findAndInvoke(SimpleInteraction.java:217) at fitnesse.slim.MethodExecutor.findAndInvoke(MethodExecutor.java:18) at fitnesse.slim.FixtureMethodExecutor.execute(FixtureMethodExecutor.java:18) at fitnesse.slim.StatementExecutor.getMethodExecutionResult(StatementExecutor.java:139) at fitnesse.slim.StatementExecutor.call(StatementExecutor.java:112) at fitnesse.slim.instructions.CallAndOptionalAssignInstruction.executeInternal(CallAndOptionalAssignInstruction.java:30) at fitnesse.slim.instructions.Instruction.execute(Instruction.java:29) at fitnesse.slim.ListExecutor$Executive.executeStatement(ListExecutor.java:49) at fitnesse.slim.ListExecutor$Executive.executeStatements(ListExecutor.java:43) at fitnesse.slim.ListExecutor.execute(ListExecutor.java:85) at fitnesse.slim.SlimServer.executeInstructions(SlimServer.java:82) at fitnesse.slim.SlimServer.processOneSetOfInstructions(SlimServer.java:75) at fitnesse.slim.SlimServer.tryProcessInstructions(SlimServer.java:62) at fitnesse.slim.SlimServer.serve(SlimServer.java:47) at fitnesse.testsystems.slim.InProcessSlimClient$1.run(InProcessSlimClient.java:55) at java.lang.Thread.run(Thread.java:748) . Page content:(Screenshot not available) |
http://testapp.galenframework.com |
Then we trigger layout verification, and check its results. Note that the full (HTML) report generated by Galen will be made available as part of the test result.
That full report will contain all details on any issues found. In the wiki test we just check: that the spec file used contained specs to be used, and how many specs caused errors/warnings.
(This test is a bit strange in that it expects errors, which you normally would not.)
script | layout test | |||
set included tags | usual,hovered | |||
|
verify layout using | http://files/galenExamples/menuHighlight.gspec | ||
check | verified spec count | 0>0 | ||
check | passed spec count | 0 | ||
check | spec error count | [0] expected [2] | ||
check | spec warning count | 0 | ||
|
layout check messages | |||
set included tags | usual | |||
set layout check name | Menu with usual highlight | |||
|
verify layout using | http://files/galenExamples/menuHighlight.gspec | ||
check | spec error count | [0] expected [1] | ||
check | spec warning count | 0 |