江苏省住房和建设部网站首页,wordpress 栏目插件,沈阳京科男科医院,线上运营怎么做一、使用场景
使用场景对应事件复制粘贴键盘事件拖动元素到某个位置鼠标事件鼠标悬停鼠标事件滚动到某个元素滚动事件使用触控笔点击触控笔事件#xff08;了解即可#xff09;
https://www.selenium.dev/documentation/webdriver/actions_api
二、ActionChains解析
实例…
一、使用场景
使用场景对应事件复制粘贴键盘事件拖动元素到某个位置鼠标事件鼠标悬停鼠标事件滚动到某个元素滚动事件使用触控笔点击触控笔事件了解即可
https://www.selenium.dev/documentation/webdriver/actions_api
二、ActionChains解析
实例化类ActionChains参数为driver实例。中间可以有多个操作。.perform()代表确定执行。
ActionChains(self.driver).操作.perform()
现在我也找了很多测试的朋友做了一个分享技术的交流群共享了很多我们收集的技术文档和视频教程。
如果你不想再体验自学时找不到资源没人解答问题坚持几天便放弃的感受
可以加入我们一起交流。而且还有很多在自动化性能安全测试开发等等方面有一定建树的技术大牛
分享他们的经验还会分享很多直播讲座和技术沙龙
可以免费学习划重点开源的
qq群号110685036 三、键盘事件
按下、释放键盘键位结合send_keys回车
3.1、键盘事件——使用shift键实现大写
mouse ActionChains(self.driver)实例化ActionChains类mouse.key_dowm(keys.SHIFT,ele)按下SHIFT键mouse.send_keys(“selenium”)输入字母自动变成大写mouse.perform()
3.2、键盘事件——输入后回车
方法1.send_keys(Keys.ENTER)方法2ActionChains().send_keys(Keys.ENTER).perform()
self.driver.find_element(By.XPATH, //input[aria-label搜索]).send_keys(Keys.ENTER)
self.action.send_keys(Keys.ENTER).perform()
3.3、键盘事件-复制粘贴
多系统兼容 mac 的复制按钮为 COMMANDwindows 的复制按钮为 CONTROL左箭头Keys.ARROW_LEFT按下COMMAND或者CONTROL: key_down(cmd_ctrl)按下剪切与粘贴按钮: send_keys(xvvvvv)
四、鼠标事件
4.1、双击
double_click(元素对象): 双击元素
def test_double_click(self):self.driver.get(https://vip.ceshiren.com/#/ui_study/frame)ele01 self.driver.find_element(By.XPATH, //button[classel-button el-button--primary])self.action.double_click(ele01).perform()time.sleep(3)
4.2、鼠标事件-拖动元素
drag_and_drop(起始元素对象, 结束元素对象): 拖动并放开元素
def test_drag_and_drop(self):self.driver.get(https://vip.ceshiren.com/#/ui_study/action_chains)ele01 self.driver.find_element(By.ID, item1)ele02 self.driver.find_element(By.ID, item3)self.action.drag_and_drop(ele01, ele02).perform()
4.3、 鼠标事件-悬浮
move_to_element(元素对象): 移动到某个元素
def test_move_to_element(self):self.driver.get(https://vip.ceshiren.com/#/ui_study/action_chains2)ele01 self.driver.find_element(By.XPATH, //div [data-v-3e28c77a and classtitle])self.action.move_to_element(ele01).perform()self.driver.find_element(By.XPATH, //*[contains(text(),管理)]).click()
五、滚轮/滚动操作
滚动到元素根据坐标滚动
注意 selenium 版本需要在 4.2 之后才支持滚动操作 5.1、滚动到元素
ActionChains().scroll_to_element().perform()
def test_scroll_to_element(self):self.driver.get(https://ceshiren.com/)ele01 self.driver.find_element(By.PARTIAL_LINK_TEXT, jmeter分布式压测创建多节点报错)self.action.scroll_to_element(ele01).perform()self.action.scroll_by_amount(0, 100).perform() ele01.click()
5.2、根据坐标滚动
ActionChains.scroll_by_amount(横坐标纵坐标)
def test_scroll_by_amount(self):self.driver.get(https://ceshiren.com/)self.action.scroll_by_amount(0, 1000).perform() 最后感谢每一个认真阅读我文章的人看着粉丝一路的上涨和关注礼尚往来总是要有的虽然不是什么很值钱的东西如果你用得到的话可以直接拿走 软件测试面试文档
我们学习必然是为了找到高薪的工作下面这些面试题是来自阿里、腾讯、字节等一线互联网大厂最新的面试资料并且有字节大佬给出了权威的解答刷完这一套面试资料相信大家都能找到满意的工作。