栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

通过selenium的类人鼠标移动

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

通过selenium的类人鼠标移动

您可以

scipy.interpolate
像在这个问题中看到的那样使用B样条曲线插值。

在这里,我将使用 B样条 示例之一来获取

x
和的值
y

import numpy as npimport scipy.interpolate as si# Curve base:points = [[0, 0], [0, 2], [2, 3], [4, 0], [6, 3], [8, 2], [8, 0]];points = np.array(points)x = points[:,0]y = points[:,1]t = range(len(points))ipl_t = np.linspace(0.0, len(points) - 1, 100)x_tup = si.splrep(t, x, k=3)y_tup = si.splrep(t, y, k=3)x_list = list(x_tup)xl = x.tolist()x_list[1] = xl + [0.0, 0.0, 0.0, 0.0]y_list = list(y_tup)yl = y.tolist()y_list[1] = yl + [0.0, 0.0, 0.0, 0.0]x_i = si.splev(ipl_t, x_list) # x interpolate valuesy_i = si.splev(ipl_t, y_list) # y interpolate values

使用

x
和值
y
,您可以使用以下方法移动鼠标光标
ActionChains

from selenium import webdriverfrom selenium.webdriver.common.action_chains import ActionChainsurl = "https://prepen.io/falldowngoboone/pen/PwzPYv"driver = webdriver.Chrome(executable_path="/home/selenium/chromedriver2.25")driver.get(url)action =  ActionChains(driver);startElement = driver.find_element_by_id('drawer')# First, go to your start point or Element:action.move_to_element(startElement);action.perform();for mouse_x, mouse_y in zip(x_i, y_i):    action.move_by_offset(mouse_x,mouse_y);    action.perform();    print(mouse_x, mouse_y)


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/633089.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号