Today I'd like to introduce one interesting instrument for automation testing - Galen framework. Obviously it's probably not the most popular or the best one but I'm sure because of some special features it'll find it's own niche on the market.
No secret that we'll do everything from scratch, so let's try that out...
1. Galen installation
Simply go to http://galenframework.com/ and download zip with binaries on Your PC.
After downloading and extracting let's add that to the path variable just for future convenience.
After all preparations traditional check in console:
And that's all what we need for the start with first test.
2. Our first test with Galen.
Besides of Galen jar in the path variable we need spec file. So let's create one in our project (any folder You want) folder. To be honest till the end, some of next steps You can find on official Galen web page - I've just tried if that example really works. So let's create "home-page.spec" in Galen_Project folder. After creation just put the exact information from screen below and save that.
Now we need to try that test, so open console, go to the project folder and paste next command "galen check home-page.spec --url http://samples.galenframework.com/tutorial1/tutorial1.html --size 640x480 --htmlreport .", press Enter and see what happens. By default Galen uses Firefox browser and I didn't check other options (in any case later in ide during writing code You can choose any other browser). As You can see from screen below test fails and there's actually even information why, which is handy.
Let's modify a bit "home-page.spec" and try again.
Now it passes and if we'll check our project folder we can find a report which is built by Galen itself.
If we need to run several spec files we just put them all after check and before url.
Now in report we can see results for different spec files.
Looks pretty simple but lets put some more magic into it. I'm using IntelliJ IDEA (community which is free) so on the several slides below shown process of project creation.
As we don't use any of build tools here - we need to add Galen jar to build path of our project. Also if You don't have Your Selenium jar in the file path You should add that too.
Final project structure shown on next screen.
I won't be original about web page for our test it's going to be Allegro as usual (hopefully they won't be mad on me for that). So we need to create "allegro-home-page.spec" first and put some information about elements from original page. In my case I'll check header, input field for search and main navigation menu. I won't describe details of that spec cause they're pretty straight forward but be sure that Galen could do much more, don't believe me? Check that out by Your own - http://galenframework.com/docs/reference-galen-spec-language-guide.
After spec file we're creating our test which is actually even more simple. So in our test file we just have to declare our Layout Report and after all checks pass it to the Report Builder which will generate report for us. Part of this code You can also find on official framework page. So lets run it.
After running we can open report which is in target/reports folder.
Galen creates simple but pretty attractive and informative report as for me. Here we can see all verification's we've done and in case of failure You'll see correct message related to that failed step.
I believe nothing to add for now beside of one short conclusion. This framework looks not really understandable from first time but it's still intuitive one so I didn't spend whole day for that. Also have to admit that we can't compare this instrument with WebDriver or another framework - but we can look on that from point of specific use - when we don't have our own matcher's for position or css checking. So no need to invent another bicycle - just add that to Your project and use where needed.
P.S. added project to the repo: https://github.com/operep/Galen_Test_Project.git, so You can simply clone that
Hi Oleksandr,
ReplyDeleteCan you add details on what version of Galen and Firefox was used for this test? I keep getting error
java.io.FileNotFoundException: homePage.gspec
at com.galenframework.speclang2.pagespec.PageSpecReader.read(PageSpecReader.java:45)
at com.galenframework.api.Galen.checkLayout(Galen.java:68)
at com.galenframework.api.Galen.checkLayout(Galen.java:59)
at com.galenframework.suite.actions.GalenPageActionCheck.execute(GalenPageActionCheck.java:53)
at com.galenframework.runner.GalenPageRunner.executeAction(GalenPageRunner.java:84)
at com.galenframework.runner.GalenPageRunner.run(GalenPageRunner.java:76)
at com.galenframework.runner.GalenBasicTestRunner.runTest(GalenBasicTestRunner.java:76)
at com.galenframework.tests.GalenBasicTest.execute(GalenBasicTest.java:55)
at com.galenframework.TestRunnable.runTest(TestRunnable.java:75)
at com.galenframework.TestRunnable.run(TestRunnable.java:101)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Let me check please - as I'm not sure now
ReplyDeleteHi,
ReplyDeleteI got the same issue on Intellij. It need gspec plugin to read the gspec file. I am not sure how to fix this. Pls go through this link : https://plugins.jetbrains.com/plugin/8302. This plugin is not working.
Is there any other way to run this?. Thanks.
is Galen framework supported in Eclipse?
ReplyDelete