Reputation: 1263
I am trying to create a test with Selenium
, WebDriverJS
and Jasmine
to verify that whenever a li
element is moved right with a drag-and-drop selection, it should not be displayed anymore. This is the snippet of my code:
it('should make the card disappear when the UI is swiped right', function() {
var card1 = driver.findElement(webdriver.By.css('.slide:nth-last-child(1)'));
var card1Move = driver.executeScript('arguments[0].setAttribute("style", "right:250px")', card1);
driver.actions()
.mouseMove(card1)
.mouseDown()
.mouseMove(card1Move)
.mouseUp()
.perform();
driver.findElement(webdriver.By.css('.slide:nth-last-child(1)')).isDisplayed()
.then(function(elem) {
expect(elem).toBe(false);
});
})
The function appear to be working, but I get the following error:
Failures:
1) Swiping method should make the card disappear when the UI is swiped right
Message:
TypeError: location.getRawId is not a function
Stack:
TypeError: location.getRawId is not a function
at webdriver.ActionSequence.mouseMove (/Users/.../node_modules/selenium-webdriver/lib/webdriver/actionsequence.js:108:46)
at Object.<anonymous> (/Users/.../tests/index.js:27:14)
According to the test, the error is in the .mouseMove(card1Move)
method.
Do you know what is causing this issue and a possible way to solve it? Thanks in advance for your replies!
Upvotes: 2
Views: 5023
Reputation: 20021
I had the same error in protractor "Failed: location.getRawId is not a function" - my issue was that the element I was searching was not to be found.
Upvotes: 1
Reputation: 4673
Currently you can also do
.dragAndDrop(card1, { x: 100, y: 0 })
which does exactly this - mouseDown(element).mouseMove(location).mouseUp()
see here
Upvotes: 2
Reputation: 26
Replace mouseMove(card1Move)
with mouseMove({x: offsetFromCenter, y: offsetFromCenter})
e.g. mouseMove({x: 100, y: 0})
will move 100px to the right of card1's center.
Upvotes: 1