编辑:如果要使用ctrl
键选择不同的元素:
client.elements(<css selector for your list of elements>, function(err, res) {
client
.moveTo(res.value[<index of element you want to select>].ELEMENT, 0, 0)
.keys('Ctrl') #every action after this within the scope of `client.elements` will have the `ctrl` key depressed
.buttonPress('left')
.moveTo(res.value[<index of element you want to select>].ELEMENT, 0, 0)
.buttonPress('left')
.moveTo(res.value[<index of element you want to select>].ELEMENT, 0, 0)
.buttonPress('left')
#repeat `.moveTo` and `.buttonPress` for every element you want to `ctrl` select
.keys('NULL'); #This command or `.keys('Shift') will release the `shift` key.
});
要使用shift
键进行选择,请使用下面的代码(假设您要选择元素列表中的每个项目——显然您可以更改索引以获取元素列表的特定子部分)。它将移动到元素列表中第一个元素的左上角,然后左键单击,然后按 shift 键,然后移动到最后一个元素的左上角,再次单击左键,然后松开shift
键:
client.elements(<css selector for your list of elements>, function(err, res) {
client
.moveTo(res.value[0].ELEMENT, 0, 0)
.buttonPress('left')
.keys('Shift')
.moveTo(res.value[(res.value.length-1)].ELEMENT, 0, 0)
.buttonPress('left')
.keys('NULL'); #This command or `.keys('Shift') will release the `shift` key.
});