Message: unknown error: Element is not clickable at point

google chrome - Debugging "Element is not clickable at point" error - Stack Overflow https://stackoverflow.com/questions/11908249/debugging-element-is-not-clickable-at-point-error

from selenium import webdriver
import os
import time
import pymysql
from bs4 import BeautifulSoup
import requests
import threading
from selenium.webdriver.common.keys import Keys h, pt, u, p, db = 'localhost', 3306, 'root', '', 'qqzone' def mysql_fetch(sql, res_type='tuple'):
global h, pt, u, p, db
try:
conn = pymysql.connect(host=h, port=pt, user=u, passwd=p, db=db, charset='utf8mb4')
except Exception as e:
print(e)
return ()
if res_type == 'dic':
cursor = conn.cursor(pymysql.cursors.DictCursor)
else:
cursor = conn.cursor()
cursor.execute(sql)
conn.commit()
r = cursor.fetchall()
cursor.close()
conn.close()
return r def mysql_write(sql):
global h, pt, u, p, db
try:
conn = pymysql.connect(host=h, port=pt, user=u, passwd=p, db=db, charset='utf8mb4')
except Exception as e:
print(e)
return 1
cursor = conn.cursor()
cursor.execute(sql)
conn.commit()
cursor.close()
conn.close()
return 0 # D:\pyaction\toutiao_team_win img_dir = 'C:/Users/Administrator/Desktop/1/toutiao_team/dl_img/'
img_dir = 'D:/pyaction/toutiao_team_win/dl_img/' import random def spider_webimg_dl_return_local_img_path(img_dir, img_url, media_type='img',
local_default='default.DONOT_REMOVE.png'):
r = '%s%s' % (img_dir, local_default) if media_type == 'img':
try:
req = requests.get(img_url)
time.sleep(3)
if req.status_code != 200:
print('-!=200')
return r
time.sleep(30)
print(img_url)
bytes = req._content
# r = '%s%s%s%s%s' % (
# img_dir, time.strftime('%Y%m%d%H%M%S', time.localtime(time.time())), str(threading.get_ident()),
# img_url.split('!/c')[0].split('/')[-1].replace('*', '_'), '.png')
# print(r) r = '%s%s%s%s%s' % (
img_dir, time.strftime('%Y%m%d%H%M%S', time.localtime(time.time())), str(threading.get_ident()),
str(random.randrange(1000, 9999)), '.png')
print(r)
filter_l = ['&', '=', '?', '-']
for fi in filter_l:
r.replace(fi, '')
if bytes != 0:
with open(r, 'wb')as f:
f.write(bytes)
except Exception as e:
print(e)
elif media_type == 'mp4':
try:
time.sleep(30) print(img_url)
r = '%s%s%s%s%s' % (
img_dir, time.strftime('%Y%m%d%H%M%S', time.localtime(time.time())), str(threading.get_ident()),
img_url.split('.mp4?')[0].split('/')[-1].replace('*', '_'), '.mp4')
print(r)
req = requests.get(img_url)
time.sleep(3)
if req.status_code != 200:
print('-!=200')
return ''
bytes = req._content
time.sleep(210)
if bytes != 0:
with open(r, 'wb')as f:
f.write(bytes)
except Exception as e:
r = ''
print(e) return r driver = webdriver.Chrome()
myurl = 'https://weibo.com/u/1779073702'
myurl = 'https://weibo.com/u/1779073702?is_all=1'
myurl = 'https://weibo.com/login.php'
driver.get(myurl)
# 此处需要内存和cpu空余,能够支持dom解析和处理重js页面
time.sleep(10)
driver.refresh()
time.sleep(10)
# xp = '//*[@id="pl_common_top"]/div/div/div[3]/div[2]/ul/li[3]/a'
# try:
# # 此处解决了不能点击该元素报错,第三次尝试ok
# driver.find_element_by_xpath(xp).click()
# time.sleep(40)
#
# except Exception as e:
# print(e)
# os._exit(1024) js = 'document.getElementsByClassName("username")[1].childNodes[0].value="welcome.cn";' \
'document.getElementsByClassName("password")[0].childNodes[0].value="p";' \
'document.getElementsByClassName("form_login_register")[0].childNodes[5].childNodes[0].click();'
js = 'document.getElementById("loginname").value="welcome.cn";' \
'document.getElementsByName("password")[0].value="p";' \
'document.getElementsByClassName("W_btn_a btn_32px")[0].click();'
try:
driver.execute_script(js)
time.sleep(30)
except Exception as e:
print(e)
os._exit(1024) time.sleep(random.randrange(3, 6))
for isc in range(2):
# 今日头条 非iframe 无限次
# qq空间说说 iframe 固定20条 2次报错
# memory cpu
time.sleep(1)
js = 'window.scrollTo(0,document.body.scrollHeight)'
driver.execute_script(js) while True:
sql = 'SELECT id, words,imgurls,time_site FROM qqzoneshuoshuo WHERE lefttimes_weibo>0 AND INSTR(imgurls,".mp4")=0 AND id IN ( SELECT MAX(id) FROM qqzoneshuoshuo GROUP BY id_site) ORDER BY time_script DESC,id ASC ;'
res_content = mysql_fetch(sql, 'dic')
print(res_content)
if len(res_content) == 0:
continue
comment_l_sq = 0
for i in res_content[0:]:
# id, words,imgurls,time_site
dbid, content, img_list, time_site = i['id'], i['words'], i['imgurls'], i['time_site']
if 1 > 13:
if '天' in time_site or '月' in time_site:
continue
lh = int(time.strftime("%H", time.localtime()))
if lh - int(time_site.split(':')[0]) >= 24:
continue
if '早安' in content and lh >= 11:
continue
elif '晚安' in content and lh <= 20:
continue time.sleep(10)
# because another element <div> obscures it
content = content.split('展开全文')[0].split('上传')[0].split('浏览')[0].replace('"', ' ').replace("'", ' ')
content = content.replace('"', ' ').replace("'", ' ').replace('\n', ' ')
filter_l = ['密龄素材空间', '评论'] for fi in filter_l:
content = content.replace(fi, ' ')
# js = 'document.getElementsByTagName("textarea")[0].value="{}新年快乐-密龄白藜芦醇DOAEZ朵韵诗-阿静艾卡尔@ http://www.icarei.cn期待与你携手前行!!";'.format(
# content)
# js = 'document.getElementsByTagName("textarea")[0].value="{}白藜芦醇-燕窝美妆-密龄DOAEZ朵韵诗-阿静艾卡尔@ http://www.icarei.cn期待与你携手前行!!";'.format(
# content)
js = 'document.getElementsByTagName("textarea")[0].value="{}南京同仁堂密龄白藜芦醇-燕窝美妆-DOAEZ朵韵诗-阿静@ http://www.icarei.cn期待与你携手前行!!";'.format(
content)
# https://item.taobao.com/item.htm?id=567557180229
ad_url_l = ['567557180229', '565875313425', '545159271159', '546048319163'] # 补水喷雾 手链 面膜 防晒喷雾
ad_url_l = ['567557180229', '565875313425', '545159271159', '546048319163', '567693004121'] # 补水喷雾 手链 面膜 防晒喷雾
ad_this = ad_url_l[int(time.time()) % len(ad_url_l)]
ad_url = 'https://item.taobao.com/item.htm?id={}'.format(ad_this)
# js = 'document.getElementsByTagName("textarea")[0].value="{}#话题# 磁石娃娃 南京同仁堂密龄白藜芦醇-燕窝美妆-DOAEZ朵韵诗-阿静@ {}!!";'.format(
# js = 'document.getElementsByTagName("textarea")[0].value="{}#doaez朵韵诗磁石娃娃燕窝润颜面膜# 磁石娃娃 南京同仁堂密龄白藜芦醇-燕窝美妆-DOAEZ朵韵诗-阿静@ {}!!";'.format(
# content, ad_url)
# print(js) hot_topic_list_url = 'https://weibo.com/u/1779073702/home'
js = 'window.location.href="{}"'.format(hot_topic_list_url)
driver.execute_script(js)
time.sleep(10) time.sleep(10)
hot_url_l = [i.get_attribute('href') for i in driver.find_elements_by_css_selector('li>p>a')] try:
hot_url_l_index = random.choice([int(time.time()) % len(hot_url_l), 0, 1])
except Exception as e:
print(e)
continue js = 'window.location.href="{}"'.format(hot_url_l[hot_url_l_index])
driver.execute_script(js)
time.sleep(10)
driver.refresh()
time.sleep(random.randrange(3, 6))
# for isc in range(2):
# # 今日头条 非iframe 无限次
# # qq空间说说 iframe 固定20条 2次报错
# # memory cpu
# time.sleep(1)
# js = 'window.scrollTo(0,document.body.scrollHeight)'
# driver.execute_script(js)
# driver.refresh() # time.sleep(10)
time.sleep(15) time.sleep(30)
comment_l = driver.find_elements_by_css_selector('.WB_row_line>li:nth-child(3)>a>span>span>span')
try:
time.sleep(30)
comment_l_sq=random.choice([0,0,int(time.time())%len(comment_l)])
comment_l[comment_l_sq].click()
time.sleep(30)
comment_l_sq += 1
comment_l_sq = 0
except Exception as e:
print(e)
continue time.sleep(12)
# '.WB_publish>div>textarea'
mytopic, myname = ' #doaez朵韵诗磁石娃娃燕窝润颜面膜# ', '南京同仁堂密龄白藜芦醇-燕窝美妆-DOAEZ朵韵诗-阿静@ '
mystr = '{}{}{}{}'.format(mytopic, myname, content, ad_url)
js = 'document.getElementsByTagName("textarea")[1].value="{}"'.format(mystr)
try:
# 需要键盘事件 - response
driver.find_elements_by_tag_name("textarea")[1].send_keys(Keys.SPACE)
time.sleep(2)
driver.find_elements_by_tag_name("textarea")[1].send_keys(Keys.BACK_SPACE)
driver.execute_script(js)
time.sleep(2)
except Exception as e:
print(e)
continue js = "document.getElementsByName('forward')[0].click();"
driver.execute_script(js)
time.sleep(2)
js = "document.getElementsByClassName('btn W_fr')[0].childNodes[0].click()"
driver.execute_script(js)
time.sleep(2) driver.refresh()
# # 先填充文本:动态d
# # om
#
# for iimg in range(2):
# js = 'document.getElementsByClassName("ficon_image")[0].click();'
# driver.execute_script(js)
# time.sleep(2)
# upload = driver.find_element_by_id('pic_upload').find_element_by_tag_name('input')
# img_url_list = img_list.split(',')
# try:
# # MAX=8
# for img_url in img_url_list:
# if '.gif' in img_url or 'qzonestyle' in img_url:
# continue
# local_img_path = spider_webimg_dl_return_local_img_path(img_dir, img_url,
# local_default='default.DONOT_REMOVE.png')
# print(local_img_path)
# time.sleep(2)
# upload.send_keys(local_img_path)
# except Exception as e:
# print(e)
# try:
# js = 'document.getElementsByClassName("W_layer_close")[0].click();document.getElementsByClassName("func")[0].childNodes[3].click();'
# driver.execute_script(js)
# time.sleep(10)
# driver.refresh()
# except:
# pass
#
# continue
#
# time.sleep(5)
# js = 'document.getElementsByClassName("W_layer_close")[0].click();document.getElementsByClassName("func")[0].childNodes[3].click();'
# # js = 'document.getElementsByTagName("textarea")[0].click();document.getElementsByClassName("func")[0].childNodes[3].click();'
# # js = 'document.getElementsByClassName("func")[0].childNodes[3].click();'
# driver.execute_script(js)
#
# time.sleep(10) sql = 'UPDATE qqzoneshuoshuo SET lefttimes_weibo=lefttimes_weibo-1 WHERE id={}'.format(dbid)
print(sql)
try:
mysql_write(sql)
except:
pass driver.refresh() time.sleep(random.randint(60 * 0.5, 60 * 1))
# 15min后刷新,循环存入数据,期间定时刷新,维持页面
for si in range(15):
try:
driver.refresh()
time.sleep(60)
time.sleep(random.randint(0, 10))
print(si)
except Exception as e:
print(145, e)

  

Message: unknown error: Element is not clickable at point的更多相关文章

  1. 关于执行webdriver.Chrome; 报错WebDriverException: Message: unknown error: Element is not clickable at point (1085, 103)

    from selenium import webdriverfrom time import sleep dr = webdriver.Chrome() dr.get("http://pj1 ...

  2. python控制selenium点击登录按钮时报错 unknown error: Element is not clickable at point

    利用python控制selenium进行一个网页的登录时报错: C:\Users\Desktop\selenium\chrome>python chrome.py selenium.common ...

  3. selenium.common.exceptions.WebDriverException: Message: unknown Error: cannot find Chrome binary

    使用Chrome浏览器时,经常会遇到以下报错:浏览器没有调用起来 selenium.common.exceptions.WebDriverException: Message: unknown Err ...

  4. Python3 Selenium自动化测试赋值出现:WebDriverException: Message: unknown error: call function result missing 'value'

    Python3 Selenium自动化测试赋值出现:WebDriverException: Message: unknown error: call function result missing ' ...

  5. selenium WebDriverException: Message: unknown error: DevToolsActivePort file doesnt exist

    在centos中使用无头chrome报以下错误 selenium.common.exceptions.WebDriverException: Message: unknown error: DevTo ...

  6. WebDriverException: Message: unknown error: Chrome failed to start: crashed

    the last answer WebDriverException: Message: unknown error: Chrome failed to start: crashed

  7. robotframework执行用例时,报错selenium.common.exceptions.WebDriverException: Message: unknown error: cannot get automation extension from unknown error: page could not be found: chrome-extension://aapnijgdinl

    在用robotframework编写移动端测试用例(用chrome浏览器模拟手机浏览器),执行用例时, 报错selenium.common.exceptions.WebDriverException: ...

  8. 不能聚焦元素问题 WebDriverException: Message: unknown error: cannot focus element

    上周碰到了 Unable to locate element,即“无法定位元素”,后靠两行代码解决: wait = ui.WebDriverWait(driver,5) wait.until(lamb ...

  9. RF运行脚本报错:WebDriverException: Message: unknown error: call function result missing

    原因:浏览器驱动与浏览器版本不对应

随机推荐

  1. Python入门之类(class)

    面向对象三大特性 面向对象的三大特性是指:封装.继承和多态. 一.封装 封装,顾名思义就是将内容封装到某个地方,以后再去调用被封装在某处的内容. 所以,在使用面向对象的封装特性时,需要: 将内容封装到 ...

  2. react初探索--react + react-router + ant-design 后台管理系统配置

    首先确认安装了node环境,Node >= 6. 如果对react 及 ant-design 一无所知,建议去阅读下api文档,react 可以在 codePen 在线练习. react Api ...

  3. 常见的awk内建变量

    FS: 输入字段分隔符变量 语法: $ awk -F 'FS' 'commands' inputfilename 或者 $ awk 'BEGIN{FS="FS";}' OFS: 输 ...

  4. linux 命令终端提示符显示-bash-4.2#解决方法

    原地址:http://blog.csdn.net/liulihui1988/article/details/52796395 终端提示符显示的是-bash-4.2# 而不是root@主机名 + 路径的 ...

  5. selenium IDE断言设置实践

    断言: 验证应用程序的状态是否同所期望的一致. 常见的断言包括:验证页面内容,如标题是否为X或当前位置是否正确等等. 断言被用于4种模式+5种手段: Assert Assert 断言失败时,该测试将终 ...

  6. STL map的用法介绍!

    map对象的定义 使用前添加map头文件,必须分别指明键和值的类型: map<string,int>word_count; map的构造函数: map<k,v>m;   创建一 ...

  7. hihoCoder 必须吐槽hihoCoder的一点 (¯Д¯)ノ

    代码输入窗口太小,mac下经常误操作:双指滑动浏览器后退 而且输入框不会自动保存,一不小心后退一下,啥都..都没了...码了好久的代码就没了..遇到不止一次了 (  ̄ .  ̄ ) (゜ ロ゜;) ( ̄ ...

  8. c/c++ 位域的概念

    位域 有些信息在存储时,并不需要占用一个完整的字节, 而只需占几个或一个二进制位.例如在存放一个开关量时,只有0和1 两种状态, 用一位二进位即可.为了节省存储空间,并使处理简便,C语言又提供了一种数 ...

  9. 前端开发:JQuery(1)

    JQuery DOM文档加载的步骤: 1. 解析HTML结构: 2. 加载外部脚本和样式: 3. 解析并执行脚本代码: 4. DOM树构建完成: 5. 加载图片等外部文件: 6. 页面加载完成: JS ...

  10. 【BZOJ2527】Meteors(整体二分)

    题意: Byteotian Interstellar Union有N个成员国.现在它发现了一颗新的星球,这颗星球的轨道被分为M份(第M份和第1份相邻),第i份上有第Ai个国家的太空站. 这个星球经常会 ...