ember-native-dom-helpers icon indicating copy to clipboard operation
ember-native-dom-helpers copied to clipboard

Clicking certain coordinates within an element

Open knownasilya opened this issue 8 years ago • 3 comments

I'd like to be able to do something like click('.my-map', { xOffset: 5, yOffset: 5 }), since there isn't usually anything to select on to click on a map if you are doing testing that requires drawing on the map, and not clicking existing objects.

knownasilya avatar May 17 '17 20:05 knownasilya

So it's possible to pass client* or screen*, but not possible to do a relative offset, which is far more useful, especially when the browser can change sizes during tests.

knownasilya avatar May 17 '17 21:05 knownasilya

@knownasilya it should be possible to build a wrapper around find() and click() that does what you're looking for. essentially something like:

async clickXY(selector, x, y) {
  let element = find(selector);
  let elementX = element.foobarX;
  let elementY = element.foobarY;
  let globalX = elementX + x;
  let globalY = elementY + y;
  await click(element, { x: globalX, y: globalY });
}

Turbo87 avatar May 17 '17 22:05 Turbo87

I also lean to think that click should remain "bare metal" and just forward options to the event, since it's pretty easy to create an utility like @Turbo87 did. With async/await and this helpers you can don't need to worry about asynchrony and that helper will work both in acceptance and integration

cibernox avatar May 18 '17 08:05 cibernox