-
-
Notifications
You must be signed in to change notification settings - Fork 208
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
403 additions
and
68 deletions.
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
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,59 @@ | ||
import chai from 'chai'; | ||
import chaiAsPromised from 'chai-as-promised'; | ||
import { AndroidDriver } from '../../..'; | ||
import sampleApps from 'sample-apps'; | ||
|
||
chai.should(); | ||
chai.use(chaiAsPromised); | ||
|
||
let driver; | ||
let animationEl; | ||
let defaultCaps = { | ||
app: sampleApps('ApiDemos-debug'), | ||
deviceName: 'Android', | ||
platformName: 'Android' | ||
}; | ||
|
||
describe('apidemo - attributes', function() { | ||
before(async () => { | ||
driver = new AndroidDriver(); | ||
await driver.createSession(defaultCaps); | ||
let animation = await driver.findElOrEls('accessibility id', 'Animation', false); | ||
animationEl = animation.ELEMENT; | ||
}); | ||
after(async () => { | ||
await driver.deleteSession(); | ||
}); | ||
it('should be able to find resourceId attribute', async () => { | ||
await driver.getAttribute('resourceId', animationEl).should.eventually.become('android:id/text1'); | ||
}); | ||
it('should be able to find text attribute', async () => { | ||
await driver.getAttribute('text', animationEl).should.eventually.become('Animation'); | ||
}); | ||
it('should be able to find name attribute', async () => { | ||
await driver.getAttribute('name', animationEl).should.eventually.become('Animation'); | ||
}); | ||
it('should be able to find name attribute, falling back to text', async () => { | ||
await driver.click(animationEl); | ||
let textView = await driver.findElOrEls('class name', 'android.widget.TextView', true); | ||
let textViewEl = textView[1].ELEMENT; | ||
await driver.getAttribute('name', textViewEl).should.eventually.become('Bouncing Balls'); | ||
await driver.back(); | ||
}); | ||
it('should be able to find displayed attribute', async () => { | ||
await driver.getAttribute('displayed', animationEl).should.eventually.become('true'); | ||
}); | ||
it('should be able to find displayed attribute through normal func', async () => { | ||
await driver.elementDisplayed(animationEl).should.eventually.become(true); | ||
}); | ||
it('should be able to get element location', async () => { | ||
let location = await driver.getLocationInView(animationEl); | ||
location.x.should.be.at.least(0); | ||
location.y.should.be.at.least(0); | ||
}); | ||
it('should be able to get element size', async () => { | ||
let size = await driver.getSize(animationEl); | ||
size.width.should.be.at.least(0); | ||
size.height.should.be.at.least(0); | ||
}); | ||
}); |
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,50 @@ | ||
import chai from 'chai'; | ||
import chaiAsPromised from 'chai-as-promised'; | ||
import { AndroidDriver } from '../../..'; | ||
import sampleApps from 'sample-apps'; | ||
|
||
chai.should(); | ||
chai.use(chaiAsPromised); | ||
|
||
let driver; | ||
let defaultCaps = { | ||
app: sampleApps('ApiDemos-debug'), | ||
deviceName: 'Android', | ||
platformName: 'Android', | ||
appActivity: "view.Controls1", | ||
unicodeKeyboard: true, | ||
resetKeyboard: true | ||
}; | ||
let unicodeImeId = 'io.appium.android.ime/.UnicodeIME'; | ||
|
||
describe('apidemo - IME', function () { | ||
before(async () => { | ||
driver = new AndroidDriver(); | ||
await driver.createSession(defaultCaps); | ||
}); | ||
beforeEach(async () => { | ||
await driver.reset(); | ||
}); | ||
after(async () => { | ||
await driver.deleteSession(); | ||
}); | ||
it('should get the default (enabled) input method', async () => { | ||
await driver.getActiveIMEEngine().should.eventually.equal(unicodeImeId); | ||
}); | ||
it('should get the available input methods', async () => { | ||
await driver.availableIMEEngines().should.eventually.have.length.at.least(4); | ||
}); | ||
it('should activate an installed input method', async () => { | ||
await driver.activateIMEEngine(unicodeImeId).should.not.be.rejected; | ||
}); | ||
it('should fail to activate an uninstalled input method', async () => { | ||
let invalidImeId = 'sdf.wer.gdasdfsf/.OsdfEfgd'; | ||
await driver.activateIMEEngine(invalidImeId).should.eventually.be.rejectedWith(/not available/); | ||
}); | ||
it('should deactivate the current input method', async () => { | ||
await driver.activateIMEEngine(unicodeImeId); | ||
await driver.getActiveIMEEngine().should.eventually.equal(unicodeImeId); | ||
await driver.deactivateIMEEngine(); | ||
await driver.getActiveIMEEngine().should.eventually.not.equal(unicodeImeId); | ||
}); | ||
}); |
52 changes: 52 additions & 0 deletions
52
test/functional/api-demos/localization/language-e2e-specs.js
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,52 @@ | ||
import chai from 'chai'; | ||
import chaiAsPromised from 'chai-as-promised'; | ||
import { AndroidDriver } from '../../../..'; | ||
import sampleApps from 'sample-apps'; | ||
|
||
chai.should(); | ||
chai.use(chaiAsPromised); | ||
|
||
let driver; | ||
let defaultCaps = { | ||
app: sampleApps('ApiDemos-debug'), | ||
deviceName: 'Android', | ||
platformName: 'Android' | ||
}; | ||
|
||
describe('Localization - language and country @skip-ci @skip-real-device', function() { | ||
before(async () => { | ||
driver = new AndroidDriver(); | ||
await driver.createSession(defaultCaps); | ||
}); | ||
after(async () => { | ||
await driver.deleteSession(); | ||
}); | ||
it('should set language to FR', async () => { | ||
await driver.adb.setDeviceLanguage('FR'); | ||
await driver.adb.getDeviceLanguage().should.eventually.equal('fr'); | ||
}); | ||
it('should set country to US', async () => { | ||
await driver.adb.setDeviceCountry('US'); | ||
await driver.adb.getDeviceCountry().should.eventually.equal('US'); | ||
}); | ||
}); | ||
|
||
describe('Localization - locale @skip-ci @skip-real-device', function() { | ||
// Stalls on API 23, works in CI | ||
beforeEach(async () => { | ||
driver = new AndroidDriver(); | ||
}); | ||
after(async () => { | ||
await driver.deleteSession(); | ||
}); | ||
it('should start as FR', async () => { | ||
let frCaps = Object.assign({}, defaultCaps, {locale: 'FR'}); | ||
await driver.createSession(frCaps); | ||
await driver.adb.getDeviceCountry().should.eventually.equal('FR'); | ||
}); | ||
it('should start as US', async () => { | ||
let usCaps = Object.assign({}, defaultCaps, {locale: 'US'}); | ||
await driver.createSession(usCaps); | ||
await driver.adb.getDeviceCountry().should.eventually.equal('US'); | ||
}); | ||
}); |
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,40 @@ | ||
import chai from 'chai'; | ||
import chaiAsPromised from 'chai-as-promised'; | ||
import { AndroidDriver } from '../../..'; | ||
import sampleApps from 'sample-apps'; | ||
import B from 'bluebird'; | ||
|
||
chai.should(); | ||
chai.use(chaiAsPromised); | ||
|
||
let driver; | ||
let defaultCaps = { | ||
app: sampleApps('ApiDemos-debug'), | ||
deviceName: 'Android', | ||
platformName: 'Android', | ||
appActivity: '.app.StatusBarNotifications' | ||
}; | ||
|
||
describe('apidemo - notifications', function () { | ||
before(async () => { | ||
driver = new AndroidDriver(); | ||
await driver.createSession(defaultCaps); | ||
}); | ||
after(async () => { | ||
await driver.deleteSession(); | ||
}); | ||
it('should open the notification shade @skip-ci', async () => { | ||
let el = await driver.findElOrEls('accessibility id', ':-|', false); | ||
await driver.click(el.ELEMENT); | ||
await driver.openNotifications(); | ||
await B.delay(500); | ||
let textViews = await driver.findElOrEls('class name', 'android.widget.TextView', true); | ||
let text = []; | ||
for (let view of textViews) { | ||
text.push(await driver.getText(view.ELEMENT)); | ||
} | ||
text.should.include('Mood ring'); | ||
await driver.keyevent(4); | ||
await driver.getText(el.ELEMENT).should.become(':-|'); | ||
}); | ||
}); |
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,46 @@ | ||
import chai from 'chai'; | ||
import chaiAsPromised from 'chai-as-promised'; | ||
import { AndroidDriver } from '../../..'; | ||
import sampleApps from 'sample-apps'; | ||
import B from 'bluebird'; | ||
|
||
chai.should(); | ||
chai.use(chaiAsPromised); | ||
|
||
let driver; | ||
let defaultCaps = { | ||
app: sampleApps('ApiDemos-debug'), | ||
deviceName: 'Android', | ||
platformName: 'Android' | ||
}; | ||
|
||
describe('apidemo - orientation', function () { | ||
before(async () => { | ||
driver = new AndroidDriver(); | ||
await driver.createSession(defaultCaps); | ||
}); | ||
after(async () => { | ||
await driver.deleteSession(); | ||
}); | ||
it('should rotate screen to landscape', async () => { | ||
await driver.setOrientation('PORTRAIT'); | ||
await B.delay(3000); | ||
await driver.setOrientation('LANDSCAPE'); | ||
await B.delay(3000); | ||
await driver.getOrientation().should.eventually.become('LANDSCAPE'); | ||
}); | ||
it('should rotate screen to landscape', async () => { | ||
await driver.setOrientation('LANDSCAPE'); | ||
await B.delay(3000); | ||
await driver.setOrientation('PORTRAIT'); | ||
await B.delay(3000); | ||
await driver.getOrientation().should.eventually.become('PORTRAIT'); | ||
}); | ||
it('should not error when trying to rotate to portrait again', async () => { | ||
await driver.setOrientation('PORTRAIT'); | ||
await B.delay(3000); | ||
await driver.setOrientation('PORTRAIT'); | ||
await B.delay(3000); | ||
await driver.getOrientation().should.eventually.become('PORTRAIT'); | ||
}); | ||
}); |
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,49 @@ | ||
import chai from 'chai'; | ||
import chaiAsPromised from 'chai-as-promised'; | ||
import { AndroidDriver } from '../../..'; | ||
import sampleApps from 'sample-apps'; | ||
import { DOMParser } from 'xmldom'; | ||
import xpath from 'xpath'; | ||
|
||
chai.should(); | ||
chai.use(chaiAsPromised); | ||
|
||
let driver; | ||
let defaultCaps = { | ||
app: sampleApps('ApiDemos-debug'), | ||
deviceName: 'Android', | ||
platformName: 'Android' | ||
}; | ||
let assertSource = async (source) => { | ||
source.should.exist; | ||
let dom = new DOMParser().parseFromString(source); | ||
let nodes = xpath.select('//android.widget.TextView[@content-desc="App"]', dom); | ||
nodes.length.should.equal(1); | ||
}; | ||
|
||
describe('apidemo - source', function () { | ||
before(async () => { | ||
driver = new AndroidDriver(); | ||
await driver.createSession(defaultCaps); | ||
}); | ||
after(async () => { | ||
await driver.deleteSession(); | ||
}); | ||
it('should return the page source', async () => { | ||
let source = await driver.getPageSource(); | ||
await assertSource(source); | ||
}); | ||
it('should get less source when compression is enabled', async () => { | ||
let getSourceWithoutCompression = async () => { | ||
await driver.updateSettings({'ignoreUnimportantViews': false}); | ||
return await driver.getPageSource(); | ||
}; | ||
let getSourceWithCompression = async () => { | ||
await driver.updateSettings({"ignoreUnimportantViews": true}); | ||
return await driver.getPageSource(); | ||
}; | ||
let sourceWithoutCompression = await getSourceWithoutCompression(); | ||
let sourceWithCompression = await getSourceWithCompression(); | ||
sourceWithoutCompression.length.should.be.greaterThan(sourceWithCompression.length); | ||
}); | ||
}); |
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,50 @@ | ||
import chai from 'chai'; | ||
import chaiAsPromised from 'chai-as-promised'; | ||
import { AndroidDriver } from '../../../..'; | ||
import sampleApps from 'sample-apps'; | ||
|
||
chai.should(); | ||
chai.use(chaiAsPromised); | ||
|
||
let driver; | ||
let defaultCaps = { | ||
app: sampleApps('ApiDemos-debug'), | ||
deviceName: 'Android', | ||
platformName: 'Android', | ||
appActivity: '.view.DragAndDropDemo' | ||
}; | ||
|
||
describe('apidemo - drag', function() { | ||
before(async () => { | ||
driver = new AndroidDriver(); | ||
await driver.createSession(defaultCaps); | ||
}); | ||
after(async () => { | ||
await driver.deleteSession(); | ||
}); | ||
it('should drag by element', async () => { | ||
let dot3 = await driver.findElOrEls('id', 'io.appium.android.apis:id/drag_dot_3', false); | ||
let dot2 = await driver.findElOrEls('id', 'io.appium.android.apis:id/drag_dot_2', false); | ||
let gestures = [ | ||
{options: {element: dot3.ELEMENT}}, | ||
{options: {element: dot2.ELEMENT}} | ||
]; | ||
await driver.doTouchDrag(gestures); | ||
let results = await driver.findElOrEls('id', 'io.appium.android.apis:id/drag_result_text', false); | ||
await driver.getText(results.ELEMENT).should.eventually.include('Dropped'); | ||
}); | ||
it('should drag by element with an offset', async () => { | ||
// reset the app | ||
await driver.reset(); | ||
|
||
let dot3 = await driver.findElOrEls('id', 'io.appium.android.apis:id/drag_dot_3', false); | ||
let dot2 = await driver.findElOrEls('id', 'io.appium.android.apis:id/drag_dot_2', false); | ||
let gestures = [ | ||
{options: {element: dot3.ELEMENT, x: 5, y: 5}}, | ||
{options: {element: dot2.ELEMENT, x: 5, y: 5}} | ||
]; | ||
await driver.doTouchDrag(gestures); | ||
let results = await driver.findElOrEls('id', 'io.appium.android.apis:id/drag_result_text', false); | ||
await driver.getText(results.ELEMENT).should.eventually.include('Dropped'); | ||
}); | ||
}); |
Oops, something went wrong.