Skip to content

Commit

Permalink
Merge pull request #74 from appium/set-url
Browse files Browse the repository at this point in the history
add setUrl command
  • Loading branch information
jlipps committed Dec 17, 2015
2 parents b7e922d + 04672ba commit 6153986
Show file tree
Hide file tree
Showing 20 changed files with 37 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ console.log(await driver.getOrientation()); // -> 'LANDSCAPE'
| `setNetworkConnection` |
| `setOrientation` |
| `setValue` |
| `setUrl` |
| `startActivity` |
| `startChromedriverProxy` |
| `stopChromedriverProxies` |
Expand Down
6 changes: 6 additions & 0 deletions lib/commands/general.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,12 @@ commands.reset = async function () {
return await this.startAUT();
};

// we override setUrl to take an android URI which can be used for deep-linking
// inside an app, similar to starting an intent
commands.setUrl = async function (uri) {
await this.adb.startUri(uri, this.opts.appPackage);
};

Object.assign(extensions, commands, helpers);
export { commands, helpers };
export default extensions;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
},
"dependencies": {
"adm-zip": "^0.4.7",
"appium-adb": "^2.0.1",
"appium-adb": "^2.2.0",
"appium-android-bootstrap": "^2.2.3",
"appium-android-ime": "^2.0.0",
"appium-base-driver": "^1.0.2",
Expand Down
File renamed without changes.
29 changes: 29 additions & 0 deletions test/functional/commands/url-e2e-specs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import { AndroidDriver } from '../../../..';

chai.should();
chai.use(chaiAsPromised);

let driver;
let defaultCaps = {
appPackage: 'com.android.browser',
appActivity: '.BrowserActivity',
deviceName: 'Android',
platformName: 'Android'
};

describe('setUrl', function(){
before(async () => {
driver = new AndroidDriver();
await driver.createSession(defaultCaps);
});
after(async () => {
await driver.deleteSession();
});
it('should be able to start a data uri via setUrl', async () => {
await driver.setUrl('http://saucelabs.com');
let el = await driver.findElOrEls('id', 'com.android.browser:id/url', false);
await driver.getText(el.ELEMENT).should.eventually.include('saucelabs.com');
});
});

0 comments on commit 6153986

Please sign in to comment.