#!/usr/bin/python
# -*- coding: UTF-8 -*-
# @Time : 2019年12月9日11:41:08
# @Author : shenghao/10347899@qq.com
'''test with selenium's move by x,y'''
from builtins import print from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
import cv2 as cv
import time, datetime, random,shutil
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.touch_actions import TouchActions
from selenium.webdriver.common.keys import Keys
from PIL import Image
import requests
from io import BytesIO
import cv2, time, sys,re
import matplotlib.pyplot as plt
import numpy as np class selenium(object):
def __init__(self):
self.headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.81 Safari/537.36"}
chrome_option = webdriver.ChromeOptions()
self.driver = webdriver.Chrome(executable_path="C:\Program Files\Python37\chromedriver.exe",
chrome_options=chrome_option)
self.driver.set_window_size(1440, 900) def visit_index(self):
self.driver.get(
"https://callback.58.com/antibot/verifycode?serialId=62cbf64a21ab4d309e722680c623a4e4_31ec33353c0648b7a5c97b1f2fb35976&code=22&sign=e6760461fc971994a2f3809ff536fbe9&namespace=anjuke_zufang_pc&url=.zu.anjuke.com%2Ffangyuan%2F1206610285371393%3Fisauction%3D1%26shangquan_id%3D1846")
try: click_status = WebDriverWait(self.driver, 5, 1).until(
EC.element_to_be_clickable((By.XPATH, "//div[@class = 'code_num']/input"))).click()
html = self.driver.find_element_by_xpath("//*").get_attribute("outerHTML")
rid = re.search("rid=(.*?)&", html).group(1)
time.sleep(1)
self.move(rid)
except:
pass def move(self,rid):
element = self.driver.find_element_by_xpath("//div[@class = 'dvc-slider__handler']")
move_list = ([100,0],[-3,0],[-4,0],[-5,0],[3,0],[2,0],[8,0],[10,0])
if element:
ActionChains(self.driver).click_and_hold(on_element=element).perform()
for m in move_list:
ActionChains(self.driver).move_by_offset(xoffset=m[0], yoffset=m[1]).perform()
time.sleep(0.2)
time.sleep(2)
self.driver.close() if __name__ == '__main__':
h = selenium()
h.visit_index()

python selenium5 模拟点击+拖动+按照指定相对坐标拖动 58同城验证码的更多相关文章

  1. python selenium4 模拟点击+拖动+保存验证码 测试对象+以验证码的返回ID保存命名 58同城验证码

    #!/usr/bin/python # -*- coding: UTF-8 -*- # @Time : 2019/12/5 17:30 # @Author : shenghao/10347899@qq ...

  2. python selenium3 模拟点击+拖动+保存验证码 测试对象 58同城验证码

    #!/usr/bin/python # -*- coding: UTF-8 -*- # @Time : 2019/12/5 17:30 # @Author : shenghao/10347899@qq ...

  3. python selenium2 模拟点击+拖动 测试对象 58同城验证码

    #!/usr/bin/python # -*- coding: UTF-8 -*- # @Time : 2019/12/5 17:30 # @Author : shenghao/10347899@qq ...

  4. python selenium1 模拟点击 测试对象 58同城验证码

    #!/usr/bin/python# -*- coding: UTF-8 -*-# @Time : 2019/12/5 17:30# @Author : shenghao/10347899@qq.co ...

  5. 如何使用python来模拟鼠标点击(将通过实例自动化模拟在360浏览器中自动搜索"python")

    一.准备工作: 安装pywin32,后面开发需要pywin32的支持,否则无法完成与windows层面相关的操作. pywin32的具体安装及注意事项: 1.整体开发环境: 基于windows7操作系 ...

  6. Android后台监控指定app的输入内容,抢红包,模拟点击原理

    Android开启辅助功能之后可以用AccessibilityService 去后台监控指定的app的输入内容,也可以监控到app的动作 以及通知栏的动作, 抢红包其实就根据通知栏出现了红包的通知消息 ...

  7. 【android】模拟点击某个指定坐标作用在View上

    /** * 模拟点击某个指定坐标作用在View上 * @param view * @param x * @param y */ public void clickView(View view,floa ...

  8. Python使用selenium模拟点击(一)

    本文适合有点Python基础阅读,(没基础的话,相对的比较蒙蔽,争取能让小白能一步一步跟上来) 2019-03-05 14:53:05 前几天由于需要到一个网站进行签到~~听说Python能够模拟请求 ...

  9. python 模拟点击微信

    from PyQt5 import QtCore,QtWidgets import win32gui, win32api, win32con # 调用win32api的模拟点击功能实现ctrl+v粘贴 ...

随机推荐

  1. 解决python 保存json到文件时 中文显示16进制编码的问题

    python 2.7 import codecs import json with codecs.open('Options.json', 'w', encoding='utf-8') as f: j ...

  2. kotlin陪伴对象

    在kotlin中并没有静态类成员的概念,但并不等于实现类似于静态类成员的功能,陪伴对象可以解决这个问题 fun main(arg: Array<String>) { val create ...

  3. SpringBoot之HandlerInterceptor拦截器的使用 ——(一)

    HandlerInterceptor简介拦截器我想大家都并不陌生,最常用的登录拦截.或是权限校验.或是防重复提交.或是根据业务像12306去校验购票时间,总之可以去做很多的事情.我仔细想了想这里我分三 ...

  4. shell编程(2)

    一.变量简介 变量是任何一种编程语言都必不可少的组成部分,变量用来存放各种数据.脚本语言在定义变量时通常不需要指明类型,直接赋值即可,shell变量也遵循这个规则. 在Bash shell 中,每一个 ...

  5. JAVA 基础编程练习题47 【程序 47 打印星号】

    47 [程序 47 打印星号] 题目:读取 7 个数(1—50)的整数值,每读取一个值,程序打印出该值个数的*. package cskaoyan; public class cskaoyan47 { ...

  6. Python3 Selenium自动化web测试 ==>FAQ:日期格式和日期字符串格式相互转换

    学习目的: 掌握python的基础应用 场景: 生成的测试日报需要加上时间戳作为唯一标志,免得文件覆盖,过往的文件丢失 因为os.rename方法要求文件名必须拼接的都是字符串 代码释义: # 日期转 ...

  7. 容器时代的持续交付工具---Drone:Drone使用

    上一篇文章里已经介绍了如何安装Drone,下面我们来看下如何使用.还是基于gogs作为git仓储. 首先打开server对应的地址,进入登录页面,输入在启动server时配置的管理员账号(对应的就是g ...

  8. 【文章存档】Local Git 如何部署分支

    又来存档文章了,链接 https://docs.azure.cn/zh-cn/articles/azure-operations-guide/app-service-web/aog-app-servi ...

  9. Linux 下清空或删除大文件内容的 5 种方法

    在 Linux 终端下处理文件时,有时我们想直接清空文件的内容但又不必使用任何 Linux 命令行编辑器 去打开这些文件.那怎样才能达到这个目的呢?在这篇文章中,我们将介绍几种借助一些实用的命令来清空 ...

  10. VC.VS版本&VC版本&OpenCV版本

    1.VS版本 与 VC版本 的对应关系,以及opencv 对 VC版本 的支持情况 - 魔法学徒 - CSDN博客.html(https://blog.csdn.net/yefcion/article ...