Common techniques
... we could describe the layout rules in simple words?
and make it consistent across different screen sizes
... we could test it on real mobile devices ?
Lets talk about...
============================================No tabs! Only spacesobject-name-1 css selector object-name-2 xpath //div[@id='some-div'] object-name-3 id some-id============================================@ tag ------------------------------object-name check-name: check-value
button near: textfield 10px right
button inside: container 10px top left
button inside: container 10px left right, 20px top bottom
caption above: description 15px# or like this description below: caption 15px
menu-item-* aligned horizontally top: menu-item-1
menu-item-* aligned horizontally all: menu-item-1
menu-item-* aligned vertically left: menu-item-1 1px
Range is the core for all checks
width: 100px
width: > 100px height: < 100px
width: 100 to 150px
width: ~ 100px width: 97 to 103px
width: 70% of screen/width
width: > 50 % of screen/width height: 50 to 60 % of screen/height
Navigation panel should stretch on mobile and tablet devices and be located under main section. But on desktop it should have static width of 300px and be on the right side of a screen near a main section
@ mobile, tablet navigation width: 100% of main/width below: main 0px @ desktop navigation width: 300px near: main 0px right
$ galen check homepage.spec --url "http://example.com" --size "400x600" --include "mobile" --htmlreport "reports-dir"
Home page on mobile device http://galenframework.com 400x800 check homepage.spec --include "mobile"
@@ Set domain galenframework.com @@ Table devices | deviceName | tags | size | | Mobile | mobile | 320x600 | | Tablet | tablet | 640x480 | | Desktop | desktop | 1024x800 | @@ Parameterized with devices Home page on ${deviceName} device http://${domain}/ ${size} check homepage.spec --include "${tags}"
=============================================== user-profile-* css #profiles .profile =============================================== [ 1 - 9 ]user-profile-@ above: user-profile-@{+1} 5px
component: specs/user-profile-component.spec
=============================================== user-profile-* css #menu ul li =============================================== [ 2 - ${count("user-profile-*")} ] user-profile-@ below: user-profile-@{-1} 5px
Homepage in Selenium Grid in Chrome selenium grid http://hostname:4444/wd/hub --page http://example.com --size 640x480 --browser Chrome --version "21.0" --platform "XP" check homepage.spec
login-button color scheme: ~2% white, > 80% #397fb8; @ login-button-highlighted login-button color scheme: ~2% white, > 80% #24a10b;
logo image: file imgs/logo.png, error 10%, tolerance 50
logo image: file imgs/logo.png, map-filter denoise 1
Galen will catch it
test("Home page on mobile device", function (){
var driver = createDriver(
"http://example.com", "1024x768");
checkLayout(driver, "home.spec", ["mobile"]);
});
var devices = {
mobile: { deviceName: "mobile",
size:"350x600", tags: ["mobile"]
},
desktop: { deviceName: "desktop",
size:"1024x768", tags:["desktop"]
}
};
forAll(devices, function (device) {
test("Home page on ${deviceName}", function (device){
var driver = createDriver(
"http://galenframework.com",
device.size);
checkLayout(driver, "homepage.spec", device.tags);
});
});
function LoginPage (driver) {
GalenPages.extend(this, driver, {
login: "#login-form .login",
password: "xpath: //input[@type='password']",
submitButton: "id: submit-button"
});
}
var loginPage = new LoginPage(driver);
loginPage.waitForIt();
loginPage.login.typeText("[email protected]");
loginPage.password.typeText("test123");
loginPage.submitButton.click();
function LoginPage (driver) {
GalenPages.extend(this, driver, {
login: "#login-form .login",
password: "xpath: //input[@type='password']",
submitButton: "id: submit-button",
loginAs: function (username, password) {
this.login.typeText(username);
this.password.typeText(password);
this.submitButton.click();
}
});
}
new LoginPage(driver)
.waitForIt()
.loginAs("[email protected]", "test123");
function LoginPage (driver) {
GalenPages.extend(this, driver, {
login: "input[name='login.username']",
password: "input[name='login.password']",
submitButton: "id: submit-button",
loginAs: function (username, password) {
var loginPage = this;
logged("Login as " + username +
" with password " + password, function() {
loginPage.login.typeText(username);
loginPage.password.typeText(password);
loginPage.submitButton.click();
}):
}
});
}
galen test . --testngreport testng.xml
What we talked about:
For more information visit GalenFramework.com project website or GitHub project page
Also you can find some interesting articles about Galen Framework on MindEngine.net blog