New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add global app
property.
#3549
Merged
Merged
Add global app
property.
#3549
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
const assert = require('assert'); | ||
|
||
describe('appium api demo', function () { | ||
after((app) => app.end()); | ||
|
||
const availableAppiumCommands = [ | ||
'startActivity', | ||
'getCurrentActivity', | ||
'getCurrentPackage', | ||
'getOrientation', | ||
'setOrientation', | ||
'getGeolocation', | ||
'setGeolocation', | ||
'pressKeyCode', | ||
'longPressKeyCode', | ||
'hideKeyboard', | ||
'isKeyboardShown', | ||
'getContexts', | ||
'getContext', | ||
'setContext' | ||
]; | ||
|
||
it('test chrome available API commands', async function () { | ||
// app variable is available globally | ||
// eslint-disable-next-line | ||
assert.strictEqual(app !== undefined, true); | ||
|
||
availableAppiumCommands.forEach((command) => { | ||
// eslint-disable-next-line | ||
assert.strictEqual(typeof app.appium[command], 'function'); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
const {strictEqual} = require('assert'); | ||
const path = require('path'); | ||
const common = require('../../../common.js'); | ||
const MockServer = require('../../../lib/mockserver.js'); | ||
const NightwatchClient = common.require('index.js'); | ||
|
||
describe('appium api demos', function () { | ||
beforeEach(function (done) { | ||
this.server = MockServer.init(undefined, {port: 4723}); | ||
this.server.on('listening', () => { | ||
done(); | ||
}); | ||
}); | ||
|
||
afterEach(function (done) { | ||
this.server.close(function () { | ||
done(); | ||
}); | ||
}); | ||
|
||
it('run appium api demo tests basic', function () { | ||
const testsPath = path.join(__dirname, '../../../apidemos/appium/appiumTest.js'); | ||
|
||
const globals = { | ||
waitForConditionPollInterval: 50, | ||
|
||
reporter(results) { | ||
if (results.lastError) { | ||
throw results.lastError; | ||
} | ||
} | ||
}; | ||
|
||
MockServer.addMock({ | ||
url: '/wd/hub/session', | ||
method: 'POST', | ||
response: JSON.stringify({ | ||
value: { | ||
sessionId: '1352110219202', | ||
version: 'TEST', | ||
platform: 'TEST' | ||
} | ||
}) | ||
}); | ||
|
||
return NightwatchClient.runTests(testsPath, { | ||
selenium: { | ||
host: 'localhost', | ||
port: 4723, | ||
start_process: false, | ||
use_appium: true | ||
}, | ||
desiredCapabilities: { | ||
browserName: '' | ||
}, | ||
output: false, | ||
skip_testcases_on_fail: false, | ||
silent: true, | ||
persist_globals: true, | ||
globals, | ||
output_folder: false | ||
}).then(_ => { | ||
strictEqual(NightwatchClient.app !== undefined, true); | ||
}); | ||
}); | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: we can use
defineProperties
, and define bothapp
andbrowser
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIUC
Object.defineProperties
cannot be used to add the same descriptor to two properties, but is used to add all the properties in one go. But since all the properties are added toNightwatch
separately in this file, it makes more sense to me to usedefineProperty
only just to have a consistent pattern through the file.But if the problem is with the repetition of the same descriptor for the two properties, we can maybe do something like this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, can you do the refactoring to avoid repeating the code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done