Skip to content

Commit 6dddc51

Browse files
committed
Update screenshot generation commands
1 parent 109ef36 commit 6dddc51

21 files changed

+70
-58
lines changed

.travis.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ matrix:
7373
script:
7474
- npm install -g appium
7575
- npm install
76-
- travis_retry npm run appium --runType=android23 --sauceLab=true --appLocation=$ANDROID_PACKAGE
76+
- appium &
77+
- travis_retry npm run appium -- --runType=android23 --sauceLab=true --appPath=$ANDROID_PACKAGE
7778
- os: linux
7879
env:
7980
- iOS="10"
@@ -82,4 +83,5 @@ matrix:
8283
script:
8384
- npm install -g appium
8485
- npm install
85-
- travis_wait travis_retry npm run appium --runType=ios-simulator103iPhone6 --sauceLab=true --appLocation=$IOS_PACKAGE
86+
- appium &
87+
- travis_wait travis_retry npm run appium -- --runType=ios-simulator103iPhone6 --sauceLab=true --appPath=$IOS_PACKAGE

generate-screenshots.js

Lines changed: 61 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,67 @@
1-
require('yargs').config({
2-
//runType: 'android23',
3-
appiumCapsLocation: 'appium.capabilities.json'
4-
});
5-
6-
const { startServer, stopServer, createDriver } = require('nativescript-dev-appium');
7-
8-
const run = async () => {
9-
await startServer();
10-
const driver = await createDriver();
11-
12-
await [
13-
'ActivityIndicator',
14-
'Button',
15-
'DatePicker',
16-
'HtmlView',
17-
'Image',
18-
'Label',
19-
'ListPicker',
20-
'ListView',
21-
'Progress',
22-
'SearchBar',
23-
'SegmentedBar',
24-
'Slider',
25-
'Switch',
26-
'TabView',
27-
'TextField',
28-
'TextView',
29-
'TimePicker',
30-
'WebView',
31-
].forEach(async (component) => {
32-
const listItem = await driver.findElementByText(component);
33-
await listItem.tap();
34-
35-
await driver._driver.sleep(500);
36-
37-
if (component === 'HtmlView' || component === 'WebView') {
38-
await driver._driver.sleep(4000);
39-
}
40-
41-
await driver.takeScreenshot(`screenshots/${component}.png`);
1+
const argv = require('yargs').argv;
2+
const AppiumDriver = require('nativescript-dev-appium/lib/appium-driver').AppiumDriver;
3+
const fs = require('fs');
424

43-
await driver.navBack();
5+
const components = [
6+
'ActivityIndicator',
7+
'Button',
8+
'DatePicker',
9+
'HtmlView',
10+
'Image',
11+
'Label',
12+
'ListPicker',
13+
'ListView',
14+
'Progress',
15+
'SearchBar',
16+
'SegmentedBar',
17+
'Slider',
18+
'Switch',
19+
'TabView',
20+
'TextField',
21+
'TextView',
22+
'TimePicker',
23+
'WebView',
24+
];
4425

45-
if (component === 'SearchBar') {
46-
await driver.navBack();
47-
}
48-
});
26+
(async function () {
27+
AppiumDriver.createAppiumDriver(4723, {
28+
isSauceLab: argv.sauceLab || false,
29+
runType: argv.runType,
30+
appPath: argv.appPath, //'nativescriptvueuitests-debug.apk',
31+
appiumCaps: require('./appium.capabilities.json')[argv.runType],
32+
verbose: argv.verbose || false,
33+
})
34+
.then(driver => run(driver))
35+
.then(() => console.log('Buh-Bye...'))
36+
.catch((err) => console.log(err));
37+
})();
4938

39+
const run = async (driver) => {
40+
for (let component of components) {
41+
await screenshotComponent(driver, component)
42+
}
5043
await driver.quit();
51-
await stopServer();
5244
};
5345

54-
run().then(() => {
55-
console.log('Buh-bye...');
56-
}).catch((err) => {
57-
console.log('Something isn\'t quite right... :(');
58-
console.error(err);
59-
});
46+
const screenshotComponent = async (driver, component) => {
47+
console.log(`>>>>> ${component} >>>>>`);
48+
49+
const listItem = await driver.findElementByText(component);
50+
await listItem.tap();
51+
52+
await driver._driver.sleep(500);
53+
54+
if (component === 'HtmlView' || component === 'WebView') {
55+
await driver._driver.sleep(4000);
56+
}
57+
58+
if (!fs.existsSync(`screenshots/${argv.runType}`)) {
59+
await fs.mkdir(`screenshots/${argv.runType}`);
60+
}
61+
62+
await driver.takeScreenshot(`screenshots/${argv.runType}/${component}.png`);
63+
await driver.navBack();
64+
if (component === 'SearchBar') {
65+
await driver.navBack();
66+
}
67+
};

package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@
1313
}
1414
},
1515
"dependencies": {
16-
"nativescript-dev-appium": "^3.0.0",
16+
"nativescript-dev-appium": "^3.1.0-2017-10-6-1",
1717
"nativescript-vue": "^0.1.12",
18-
"tns-core-modules": "^3.2.0"
18+
"tns-core-modules": "^3.2.0",
19+
"yargs": "^9.0.1"
1920
},
2021
"devDependencies": {
2122
"appium": "^1.7.1",
@@ -37,7 +38,8 @@
3738
"ci.android.build": "tns build android",
3839
"ci.android.screenshots": "npm run appium --runtype=android23 --sauceLab=true",
3940
"ci.ios.build": "tns build ios",
40-
"ci.ios.screenshots": "npm run appium --runtype=ios-simulator103iPhone6 --sauceLab=true"
41+
"ci.ios.screenshots": "npm run appium --runtype=ios-simulator103iPhone6 --sauceLab=true",
42+
"e2e": "mocha --opts ./e2e/config/mocha.opts"
4143
},
4244
"jest": {
4345
"testPathIgnorePatterns": [

screenshots/ActivityIndicator.png

-5.84 KB
Loading

screenshots/Button.png

-5.33 KB
Loading

screenshots/DatePicker.png

-8.14 KB
Loading

screenshots/HtmlView.png

-5.15 KB
Loading

screenshots/Image.png

-6.11 KB
Loading

screenshots/Label.png

-5 KB
Loading

screenshots/ListPicker.png

-7.36 KB
Loading

0 commit comments

Comments
 (0)