Skip to content

refactor: removed moveto command #9113

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 2 additions & 38 deletions javascript/node/selenium-webdriver/lib/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,43 +125,6 @@ class LegacyActionSequence {
}
}

/**
* Moves the mouse. The location to move to may be specified in terms of the
* mouse's current location, an offset relative to the top-left corner of an
* element, or an element (in which case the middle of the element is used).
*
* @param {(!./webdriver.WebElement|{x: number, y: number})} location The
* location to drag to, as either another WebElement or an offset in
* pixels.
* @param {{x: number, y: number}=} opt_offset If the target {@code location}
* is defined as a {@link ./webdriver.WebElement}, this parameter defines
* an offset within that element. The offset should be specified in pixels
* relative to the top-left corner of the element's bounding box. If
* omitted, the element's center will be used as the target offset.
* @return {!LegacyActionSequence} A self reference.
*/
mouseMove(location, opt_offset) {
let cmd = new command.Command(command.Name.LEGACY_ACTION_MOUSE_MOVE)

if (typeof location.x === 'number') {
setOffset(/** @type {{x: number, y: number}} */ (location))
} else {
cmd.setParameter('element', location.getId())
if (opt_offset) {
setOffset(opt_offset)
}
}

this.schedule_('mouseMove', cmd)
return this

/** @param {{x: number, y: number}} offset The offset to use. */
function setOffset(offset) {
cmd.setParameter('xoffset', offset.x || 0)
cmd.setParameter('yoffset', offset.y || 0)
}
}

/**
* Schedules a mouse action.
* @param {string} description A simple descriptive label for the scheduled
Expand Down Expand Up @@ -389,7 +352,8 @@ class LegacyActionSequence {
* @return {!LegacyActionSequence} A self reference.
* @throws {Error} If the key is not a valid modifier key.
*/
sendKeys(var_args) { // eslint-disable-line
sendKeys(var_args) {
// eslint-disable-line
let keys = flatten(arguments)
return this.scheduleKeyboardAction_('sendKeys', keys)
}
Expand Down
1 change: 0 additions & 1 deletion javascript/node/selenium-webdriver/lib/command.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ const Name = {
LEGACY_ACTION_DOUBLE_CLICK: 'legacyAction:doubleclick',
LEGACY_ACTION_MOUSE_DOWN: 'legacyAction:mouseDown',
LEGACY_ACTION_MOUSE_UP: 'legacyAction:mouseUp',
LEGACY_ACTION_MOUSE_MOVE: 'legacyAction:mouseMove',
LEGACY_ACTION_SEND_KEYS: 'legacyAction:sendKeys',
LEGACY_ACTION_TOUCH_DOWN: 'legacyAction:touchDown',
LEGACY_ACTION_TOUCH_UP: 'legacyAction:touchUp',
Expand Down
1 change: 0 additions & 1 deletion javascript/node/selenium-webdriver/lib/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,6 @@ const COMMAND_MAP = new Map([
],
[cmd.Name.LEGACY_ACTION_MOUSE_DOWN, post('/session/:sessionId/buttondown')],
[cmd.Name.LEGACY_ACTION_MOUSE_UP, post('/session/:sessionId/buttonup')],
[cmd.Name.LEGACY_ACTION_MOUSE_MOVE, post('/session/:sessionId/moveto')],
[cmd.Name.LEGACY_ACTION_SEND_KEYS, post('/session/:sessionId/keys')],
[cmd.Name.LEGACY_ACTION_TOUCH_DOWN, post('/session/:sessionId/touch/down')],
[cmd.Name.LEGACY_ACTION_TOUCH_UP, post('/session/:sessionId/touch/up')],
Expand Down
35 changes: 2 additions & 33 deletions javascript/node/selenium-webdriver/lib/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@ class FileDetector {
* @return {!Promise<string>} A promise for the processed file path.
* @package
*/
handleFile(driver, path) { // eslint-disable-line
handleFile(driver, path) {
// eslint-disable-line
return Promise.resolve(path)
}
}
Expand Down Expand Up @@ -1146,38 +1147,6 @@ async function executeLegacy(executor, sequences) {
)
break
}
case Action.Type.POINTER_MOVE: {
if (action.origin === Origin.VIEWPORT) {
throw new UnsupportedOperationError(
`pointer movements relative to ${Origin.VIEWPORT} are not` +
' supported in bridge mode'
)
}

let x = action.x
let y = action.y
const cmd = new Command(Name.LEGACY_ACTION_MOUSE_MOVE)
if (action.origin && action.origin !== Origin.POINTER) {
const el = /** @type {!./webdriver.WebElement} */ (action.origin)

// Need to translate frame of reference from center of element's first
// client rect to the top-left of its bounding client rect. See:
// https://w3c.github.io/webdriver/webdriver-spec.html#dfn-center-point
let diff = await executor.execute(
new Command(Name.EXECUTE_SCRIPT)
.setParameter('script', INTERNAL_COMPUTE_OFFSET_SCRIPT)
.setParameter('args', [el])
)
x += diff[0]
y += diff[1]

const id = await el.getId()
cmd.setParameter('element', id)
}
cmd.setParameter('xoffset', x).setParameter('yoffset', y)
await executor.execute(cmd)
break
}
default: {
throw new UnsupportedOperationError(
`${action.type} actions not supported in bridge mode`
Expand Down
44 changes: 0 additions & 44 deletions javascript/node/selenium-webdriver/test/lib/input_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1088,14 +1088,6 @@ describe('input.Actions', function () {
args: [element],
},
},
{
name: command.Name.LEGACY_ACTION_MOUSE_MOVE,
parameters: {
element: 'abc123',
xoffset: 0,
yoffset: 0,
},
},
{
name: command.Name.LEGACY_ACTION_CLICK,
parameters: { button: input.Button.LEFT },
Expand Down Expand Up @@ -1269,14 +1261,6 @@ describe('input.Actions', function () {
args: [element],
},
},
{
name: command.Name.LEGACY_ACTION_MOUSE_MOVE,
parameters: {
element: 'abc123',
xoffset: 7,
yoffset: 10,
},
},
{
name: command.Name.LEGACY_ACTION_DOUBLE_CLICK,
parameters: { button: input.Button.LEFT },
Expand Down Expand Up @@ -1347,22 +1331,10 @@ describe('input.Actions', function () {
args: [element],
},
},
{
name: command.Name.LEGACY_ACTION_MOUSE_MOVE,
parameters: {
element: 'abc123',
xoffset: -1,
yoffset: 14,
},
},
{
name: command.Name.LEGACY_ACTION_CLICK,
parameters: { button: input.Button.LEFT },
},
{
name: command.Name.LEGACY_ACTION_MOUSE_MOVE,
parameters: { xoffset: 10, yoffset: 15 },
},
{
name: command.Name.LEGACY_ACTION_DOUBLE_CLICK,
parameters: { button: input.Button.LEFT },
Expand Down Expand Up @@ -1425,14 +1397,6 @@ describe('input.Actions', function () {
args: [e1],
},
},
{
name: command.Name.LEGACY_ACTION_MOUSE_MOVE,
parameters: {
element: 'abc123',
xoffset: 15,
yoffset: 20,
},
},
{
name: command.Name.LEGACY_ACTION_MOUSE_DOWN,
parameters: { button: input.Button.LEFT },
Expand All @@ -1444,14 +1408,6 @@ describe('input.Actions', function () {
args: [e2],
},
},
{
name: command.Name.LEGACY_ACTION_MOUSE_MOVE,
parameters: {
element: 'def456',
xoffset: 25,
yoffset: 30,
},
},
{
name: command.Name.LEGACY_ACTION_MOUSE_UP,
parameters: { button: input.Button.LEFT },
Expand Down