Skip to content

Commit

Permalink
[js] "fix" actions tests for chrome by wrapping spec in an extra desc…
Browse files Browse the repository at this point in the history
…ribe block.

This appears to be necessary for the afterEach hook to properly
run and clear action state between tests. This appears to be a timing
issue around mocha and not a problem with the driver itself: adding
an extra `driver.actions().clear()` call directly to the test seemed
to work.

I should dig into this more, but this test gets things passing without
unnecessarily slowing things down (to launch a new browser session)
or introducing too big of a hack.
  • Loading branch information
jleyba committed Jun 6, 2019
1 parent 02817a2 commit 49e0260
Showing 1 changed file with 23 additions and 16 deletions.
39 changes: 23 additions & 16 deletions javascript/node/selenium-webdriver/test/actions_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,22 +102,29 @@ test.suite(function(env) {
assert.equal(await box.getAttribute('class'), 'blue');
});

it('dragAndDrop()', async function() {
await driver.get(fileServer.whereIs('/data/actions/drag.html'));

let slide = await driver.findElement(By.id('slide'));
assert.equal(await slide.getCssValue('left'), '0px');
assert.equal(await slide.getCssValue('top'), '0px');

let br = await driver.findElement(By.id('BR'));
await driver.actions({bridge: true}).dragAndDrop(slide, br).perform();
assert.equal(await slide.getCssValue('left'), '206px');
assert.equal(await slide.getCssValue('top'), '206px');

let tr = await driver.findElement(By.id('TR'));
await driver.actions({bridge: true}).dragAndDrop(slide, tr).perform();
assert.equal(await slide.getCssValue('left'), '206px');
assert.equal(await slide.getCssValue('top'), '1px');
// For some reason for Chrome 75 we need to wrap this test in an extra
// describe for the afterEach hook above to properly clear action sequences.
// This appears to be a quirk of the timing around mocha tests and not
// necessarily a bug in the chromedriver.
// TODO(jleyba): dig into this more so we can remove this hack.
describe('dragAndDrop()', function() {
it('', async function() {
await driver.get(fileServer.whereIs('/data/actions/drag.html'));

let slide = await driver.findElement(By.id('slide'));
assert.equal(await slide.getCssValue('left'), '0px');
assert.equal(await slide.getCssValue('top'), '0px');

let br = await driver.findElement(By.id('BR'));
await driver.actions({bridge: true}).dragAndDrop(slide, br).perform();
assert.equal(await slide.getCssValue('left'), '206px');
assert.equal(await slide.getCssValue('top'), '206px');

let tr = await driver.findElement(By.id('TR'));
await driver.actions({bridge: true}).dragAndDrop(slide, tr).perform();
assert.equal(await slide.getCssValue('left'), '206px');
assert.equal(await slide.getCssValue('top'), '1px');
});
});

it('move()', async function() {
Expand Down

0 comments on commit 49e0260

Please sign in to comment.