Skip to content

Commit

Permalink
Set default window after get url
Browse files Browse the repository at this point in the history
  • Loading branch information
ziczhu committed May 4, 2016
1 parent 8432d04 commit 930c9c4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
8 changes: 0 additions & 8 deletions lib/controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,6 @@ controllers.url = function *() {
return latestPage.url;
};

controllers.get = function *(url) {
if (this.isSafari) {
return yield this.sim.openURL(url);
} else {
return yield this.remote.navigateTo(url);
}
};

controllers.forward = function *() {
return yield this.execute('history.forward()');
};
Expand Down
22 changes: 16 additions & 6 deletions lib/macaca-ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,6 @@ IOS.prototype.startSafari = function *(caps) {
yield this.remote.connect(pageId);
this.context = pageId;
yield this.deleteWindow();
yield _.sleep(1000);
availablePages = yield this.remote.getPages();
latestPage = _.last(availablePages);
pageId = latestPage.id;
yield this.remote.connect(pageId);
this.context = pageId;
return caps;
};

Expand Down Expand Up @@ -367,6 +361,22 @@ IOS.prototype.setContext = function *(name) {
}
};


IOS.prototype.get = function *(url) {
if (this.isSafari) {
yield this.sim.openURL(url);
yield _.sleep(2000);
const availablePages = yield this.remote.getPages();
const latestPage = _.last(availablePages);
const pageId = latestPage.id;
yield this.remote.connect(pageId);
this.context = pageId;
return null;
} else {
return yield this.remote.navigateTo(url);
}
};

IOS.prototype.getWindows = function *() {
if (!this.isSafari) {
throw new errors.NoSuchWindow();
Expand Down

0 comments on commit 930c9c4

Please sign in to comment.