Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Add in new getElementRect which superceded getElementLocation and getElementSize #116

Closed
wants to merge 2 commits into from

4 participants

@AutomatedTester
Collaborator

This has been updated in the WebDriver Spec and has landed in Gecko

@gaye
Owner

@AutomatedTester Looks good! Would you mind adding a test to https://github.com/mozilla-b2g/marionette-js-client/blob/master/test/integration/element-test.js that creates an element then positions and sizes it and then asserts that getElementRect returns the right stuff?

@gaye
Owner

Right now those tests are a bit "ghetto" (they use the mozilla.org website, but if you can get past that bit... ;)

@hfiguiere
Collaborator

And if the

npm ERR! stack Error: EACCES, unlink '/usr/lib/node_modules/marionette-client'

can be fixed.

Can't run tests on here.

@gaye
Owner

@hub: The issue is that we're trying to test your new version of the client by using it in marionette-js-runner. The way we do that is by running npm link and your global node modules are in a higher-privilege fs location (mine are too). One "hack" is to run

sudo make link
# Go into the Makefile and remove test-integration's dependency on link
make test

There's probably something smarter to do though...

@AutomatedTester
Collaborator

@gaye Added test. It's ok for this type of test and is tested properly in Mozilla-Central

@gaye gaye commented on the diff
test/integration/element-test.js
@@ -59,4 +59,14 @@ suite('element methods', function() {
var font = body.cssProperty('font-size');
assert.ok(font, 'returns a css property value');
});
+
+ test('#rect', function () {
+ var accordian = client.findElement('.accordian');
@gaye Owner
gaye added a note

Hrm I guess I was hoping that this test would inject an element that it knew about into the DOM. The integration tests seem borked at the moment, so (even though I know I asked for one) let's just land this without the integration test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@lightsofapollo

landed as 479c649

@AutomatedTester AutomatedTester deleted the AutomatedTester:1040110 branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 17, 2014
  1. @AutomatedTester
Commits on Jul 18, 2014
  1. @AutomatedTester
This page is out of date. Refresh to see the latest.
View
15 lib/marionette/element.js
@@ -332,6 +332,21 @@
},
/**
+ * Returns the object with:
+ * x and y location of the element
+ * height and width of the element
+ * @method rect
+ * @param {Function} callback [Error err, Object rect]
+ * @return {Object} self.
+ */
+ rect: function rect (callback) {
+ var cmd = {
+ name: 'getElementRect'
+ };
+ return this._sendCommand(cmd, 'value', callback);
+ },
+
+ /**
* Returns the value of the specified CSS property name.
*
* @method cssProperty
View
10 test/integration/element-test.js
@@ -59,4 +59,14 @@ suite('element methods', function() {
var font = body.cssProperty('font-size');
assert.ok(font, 'returns a css property value');
});
+
+ test('#rect', function () {
+ var accordian = client.findElement('.accordian');
@gaye Owner
gaye added a note

Hrm I guess I was hoping that this test would inject an element that it knew about into the DOM. The integration tests seem borked at the moment, so (even though I know I asked for one) let's just land this without the integration test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ var accordianRect = accordian.rect();
+ assert.ok(rect.x, "is in the object");
+ assert.ok(rect.y, "is in the object");
+ assert.ok(rect.height, "is in the object");
+ assert.ok(rect.width, "is in the object");
+
+ })
});
View
1  test/marionette/element-test.js
@@ -261,5 +261,6 @@ suite('marionette/element', function() {
simpleCommand('displayed', 'isElementDisplayed', 'value');
simpleCommand('size', 'getElementSize', 'value');
simpleCommand('location', 'getElementPosition', 'value');
+ simpleCommand('rect', 'getElementRect', 'value')
});
Something went wrong with that request. Please try again.