From d3696902cdca43514db5c4ba799e4b12489f46dc Mon Sep 17 00:00:00 2001 From: Vasyl Vavrychuk Date: Wed, 18 Dec 2013 02:19:45 +0200 Subject: [PATCH] added element post/get commands --- web/WebDriverJsDemo.html | 58 ++++++++++++++++++++++++++++------- web/webdriver-app.js | 65 ++++++++++++++++++++++++++++++++++++---- 2 files changed, 106 insertions(+), 17 deletions(-) diff --git a/web/WebDriverJsDemo.html b/web/WebDriverJsDemo.html index 8ba341c5..b99d6141 100644 --- a/web/WebDriverJsDemo.html +++ b/web/WebDriverJsDemo.html @@ -1,5 +1,6 @@ + @@ -49,17 +54,48 @@ -
- Find element by - - - - +
+ + + + + + + + + +
+ Find element by + + + + + + + + + + +
diff --git a/web/webdriver-app.js b/web/webdriver-app.js index 43e136ff..456e222b 100644 --- a/web/webdriver-app.js +++ b/web/webdriver-app.js @@ -555,10 +555,13 @@ WebDriverJsView.prototype.setFoundElementId = function(id) { var element = document.getElementById('foundElement'); if (typeof id.ELEMENT === 'string') { element.innerHTML = 'Found element ' + id.ELEMENT; + element.style.visibility = 'visible'; + document.getElementById('elementActions').style.visibility = 'visible'; } else { - element.innerHTML = id.ELEMENT.message; + element.style.visibility = 'hidden'; + this.setError(id.ELEMENT.message); + document.getElementById('elementActions').style.visibility = 'hidden'; } - element.style.visibility = 'visible'; } WebDriverJsView.prototype.setError = function(message) { @@ -669,6 +672,60 @@ WebDriverJsController.prototype.onFindElement = function() { }); }; +WebDriverJsController.prototype.onElementClick = function() { + this.element.click(); +}; + +WebDriverJsController.prototype.onElementSubmit = function() { + this.element.submit(); +}; + +WebDriverJsController.prototype.onElementClear = function() { + this.element.clear(); +}; + +WebDriverJsController.prototype.onElementTagName = function() { + this.element.getTagName().then(function(value) { + alert('Element tag name: ' + value); + }); +}; + +WebDriverJsController.prototype.onElementText = function() { + this.element.getText().then(function(value) { + alert('Element text: ' + value); + }); +}; + +WebDriverJsController.prototype.onElementLocation = function() { + this.element.getLocation().then(function(value) { + alert('Element location: ' + JSON.stringify(value)); + }); +}; + +WebDriverJsController.prototype.onElementSize = function() { + this.element.getSize().then(function(value) { + alert('Element size: ' + JSON.stringify(value)); + }); +}; + +WebDriverJsController.prototype.onElementIsSelected = function() { + this.element.isSelected().then(function(value) { + alert('Element selection: ' + value); + }); +}; + +WebDriverJsController.prototype.onElementIsEnabled = function() { + this.element.isEnabled().then(function(value) { + alert('Element enabled: ' + value); + }); +}; + +WebDriverJsController.prototype.onElementIsDisplayed = function() { + this.element.isDisplayed().then(function(value) { + alert('Element displayed: ' + value); + }); +}; + WebDriverJsController.prototype.onSendKeys = function(key) { if (this.element) { this.element.sendKeys(key); @@ -677,10 +734,6 @@ WebDriverJsController.prototype.onSendKeys = function(key) { } }; -WebDriverJsController.prototype.onClick = function() { - this.element.click(); -}; - WebDriverJsController.prototype.onListWindowHandles = function() { var self = this; var select = document.getElementById('windowList');