python + selenium的问题汇总


1.selenium.common.exceptions.WebDriverException: Message: POST /session/9a45507e-e1b6-4d8f-ad9b-fe4ce8d19555/actions did not match a known command
 
问题原因:火狐和geckodriver的一个bug
解决办法: 用旧版本的火狐就没问题

2.selenium.common.exceptions.WebDriverException: Message: Expected [object Undefined] undefined to be a string
 
问题原因:火狐浏览器版本太高导致的
解决办法: 用低版本Firfox,关闭浏览器自动升级

3.Chromedriver.exe已停止工作
 
问题原因:谷歌和driver驱动版本不匹配
解决办法:下载相匹配的驱动版本

4.Selenium 在启动 IE11 浏览器的时候不执行代码
问题原因:暂时不知道原因

5.用python发送的邮件被当成垃圾邮件退信[user = '1416438956@qq.com',password = "flmfetkcalvvgfgc"]
问题原因:被发送的邮箱没有启用IMAP/SMTP服务
解决办法:开启邮箱IMAP/SMTP服务

6.smtplib.SMTPAuthenticationError: (530, 'Error: A secure connection is requiered(such as ssl). More information at         http://service.mail.qq.com/cgi-bin/help?id=28')
问题原因:发送邮箱没有开启IMAP/SMTP服务
解决办法:开启邮箱IMAP/SMTP服务[smtp = smtplib.SMTP_SSL() QQ邮箱发送需要修改成这样]

7.发邮件带附件发送,html文件发送过去变成了att000.bat文件
问题原因:暂时不知道原因
解决办法:att = MIMEApplication(open('D:\work\autotest\workspace\demo\report\2017-07-01_15_31_18result.html',                                                                                      'rb').read())
                att.add_header('Content-Disposition', 'attachment', filename="2017-07-01_15_31_18result.html")
                msgRoot.attach(att)

8.运行java -jar selenium-server-2.48.2.jar 
  • from selenium import selenium报错(网上下载selenium rc,解压放到python的selenium文件夹中)
  • Exception: Failed to start new browser session(添加firefox的启动文件到环境变量path中)
  • echo  %path% 查看环境变量设置情况(设置完环境变量重新运行selenium server)
  • sel = selenium("localhost", 4444, "*firefox D:\Program Files (x86)\Mozilla Firefox\firefox.exe", "https://www.baidu.com") (依然报错就写上浏览器的绝对路径)
  • 启动http://127.0.0.1:4444/grid/console报错(HTTP ERROR: 403) 
  • 启动hub节点的时候端口被占用:java.net.BindException: Address already in use: bind
          (1)netstat -ano    (2)netstat -aon|findstr "4444"    (3)tasklist|findstr 
  • Firefox无法在***找到该文件(火狐版本太高了,降低火狐版本)

9.selenium 启动谷歌浏览器之后闪退

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
原文地址:https://www.cnblogs.com/ybcao/p/7340857.html