get css properties for webview elements

This commit is contained in:
Jonathan Lipps
2013-03-19 16:27:14 -07:00
parent 972f0c11cb
commit 00f034b542
5 changed files with 39 additions and 2 deletions
+5 -1
View File
@@ -361,7 +361,11 @@ Android.prototype.elementEnabled = function(elementId, cb) {
};
Android.prototype.elementSelected = function(elementId, cb) {
cb(new NotYetImplementedError(), null);
cb(new NotYetImplementedError(), null);
};
Android.prototype.getCssProperty = function(elementId, propertyName, cb) {
cb(new NotYetImplementedError(), null);
};
Android.prototype.getPageSource = function(cb) {
+7
View File
@@ -307,6 +307,13 @@ exports.getAttribute = function(req, res) {
req.device.getAttribute(elementId, attributeName, getResponseHandler(req, res));
};
exports.getCssProperty = function(req, res) {
var elementId = req.params.elementId
, propertyName = req.params.propertyName;
req.device.getCssProperty(elementId, propertyName, getResponseHandler(req, res));
};
exports.getLocation = function(req, res) {
var elementId = req.params.elementId;
+11
View File
@@ -768,6 +768,17 @@ IOS.prototype.elementSelected = function(elementId, cb) {
}
};
IOS.prototype.getCssProperty = function(elementId, propertyName, cb) {
if (this.curWindowHandle) {
this.useAtomsElement(elementId, cb, _.bind(function(atomsElement) {
this.remote.executeAtom('get_value_of_css_property', [atomsElement,
propertyName], cb);
}, this));
} else {
cb(new NotImplementedError(), null);
}
};
IOS.prototype.getPageSource = function(cb) {
if (this.curWindowHandle) {
this.remote.execute('document.getElementsByTagName("html")[0].outerHTML',
+1 -1
View File
@@ -36,6 +36,7 @@ module.exports = function(appium) {
rest.get('/wd/hub/session/:sessionId?/element/:elementId?/size', controller.getSize);
rest.get('/wd/hub/session/:sessionId?/element/:elementId?/pageIndex', controller.getPageIndex);
rest.get('/wd/hub/session/:sessionId?/element/:elementId?/attribute/:name', controller.getAttribute);
rest.get('/wd/hub/session/:sessionId?/element/:elementId?/css/:propertyName', controller.getCssProperty);
rest.post('/wd/hub/session/:sessionId?/element/:elementId?/clear', controller.clear);
rest.post('/wd/hub/session/:sessionId?/frame', controller.frame);
rest.post('/wd/hub/session/:sessionId?/keys', controller.keys);
@@ -110,7 +111,6 @@ var routeNotYetImplemented = function(rest) {
rest.get('/wd/hub/session/:sessionId?/element/:elementId?/name', controller.notYetImplemented);
rest.get('/wd/hub/session/:sessionId?/element/:elementId?/equals/:other', controller.notYetImplemented);
rest.get('/wd/hub/session/:sessionId?/element/:elementId?/location_in_view', controller.notYetImplemented);
rest.get('/wd/hub/session/:sessionId?/element/:elementId?/css/:propertyname', controller.notYetImplemented);
rest.post('/wd/hub/session/:sessionId?/moveto', controller.notYetImplemented);
rest.post('/wd/hub/session/:sessionId?/click', controller.notYetImplemented);
rest.post('/wd/hub/session/:sessionId?/buttondown', controller.notYetImplemented);
+15
View File
@@ -261,6 +261,21 @@ module.exports.buildTests = function(webviewType) {
});
});
desc('css properties', function(h) {
it('should be able to get css properties', function(done) {
loadWebView(h.driver, function() {
h.driver.elementById('fbemail', function(err, el) {
should.not.exist(err);
el.getComputedCss('background-color', function(err, bg) {
should.not.exist(err);
bg.should.equal("rgba(255, 255, 255, 1)");
done();
});
});
});
});
});
desc('getSize', function(h) {
it('should return the right size', function(done) {
loadWebView(h.driver, function() {