Skip to content

Commit

Permalink
WebDriverJs app: nicer work with active window
Browse files Browse the repository at this point in the history
  • Loading branch information
Vasyl Vavrychuk committed Dec 17, 2013
1 parent 6a22d09 commit bfe1a28
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions web/webdriver-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -682,24 +682,34 @@ WebDriverJsController.prototype.onClick = function() {
};

WebDriverJsController.prototype.onListWindowHandles = function() {
var self = this;
var select = document.getElementById('windowList');
this.driver.getAllWindowHandles().then(function(handles) {
select.innerHTML = '';
for (var handleIndex in handles) {
var handle = handles[handleIndex];
var item = document.createElement('option');
item.setAttribute('value', handle);
item.innerHTML = handle;
select.appendChild(item)
}
document.getElementById('windowList').style.visibility = 'visible';
document.getElementById('chooseWindow').style.visibility = 'visible';
this.driver.getWindowHandle().then(function(activeWindowHandle) {
self.driver.getAllWindowHandles().then(function(handles) {
select.innerHTML = '';
for (var handleIndex in handles) {
var handle = handles[handleIndex];
var item = document.createElement('option');
item.setAttribute('value', handle);
item.innerHTML = handle;
if (activeWindowHandle == handle) {
item.innerHTML += ' (active)';
item.selected = true;
}
select.appendChild(item)
}
document.getElementById('windowList').style.visibility = 'visible';
document.getElementById('chooseWindow').style.visibility = 'visible';
});
});
};

WebDriverJsController.prototype.onChooseWindow = function() {
var self = this;
var handle = document.getElementById('windowList').value;
this.driver.switchTo().window(handle);
this.driver.switchTo().window(handle).then(function() {
self.onListWindowHandles();
});
};

WebDriverJsController.prototype.onSetWindowSize = function() {
Expand Down

0 comments on commit bfe1a28

Please sign in to comment.