【问题标题】:Typing a date (element.send_keys) with Selenium/python/chromedriver, element.submit() crashes EMS web app使用 Selenium/python/chromedriver 键入日期 (element.send_keys),element.submit() 会导致 EMS Web 应用程序崩溃
【发布时间】:2019-03-11 09:47:57
【问题描述】:

网站上有一个日历,我正在尝试使用 Selenium/Python/Chromedriver 选择某个日期以修改给定日期的日程安排。

time.sleep(5)
inputElement = browser.find_element_by_xpath("//input[@type='text']")
time.sleep(5)
#I clear the date that is set before
inputElement.send_keys("\b\b\b\b\b\b\b\b\b\b\b\b\b\b16/10/2018")
time.sleep(5)
inputElement.submit()

代码很好,但在网页上我得到了这个:

EMS Web App 是一个日历应用程序,这里是网站: https://www.emssoftware.com/resources/ems-web-app-datasheet#!

这不是我尝试使用的网站,而是 EMS WEB 应用程序的网站。由于需要凭证,我无法提供相关网站。 我有没有机会用 Selenium 处理它?为什么这部分网站的行为不同?我是 Selenium 和所有这些东西的新手。

【问题讨论】:

  • https://www.emssoftware.com/resources/ems-web-app-datasheet# 页面上的哪个字段?
  • 对不起,这是EMS web app的网站!我无法发布我正在使用的网站,因为需要凭据。
  • 用相关的HTML更新问题
  • 我无法提供相关的 HTML:您需要凭据才能访问该页面。
  • 您是否在无头模式下运行您的 brawser,即,您能看到屏幕上正在执行的操作吗?如果是这样,您尝试设置的值是否正确填写?

标签: python python-2.7 selenium selenium-chromedriver


【解决方案1】:

在发送键值之前,您可以使用其他更常用的方法来清除字段:

time.sleep(5)
inputElement = browser.find_element_by_xpath("//input[@type='text']")
time.sleep(5)
#I clear the date that is set before
inputElement.clear()
inputElement.send_keys("16/10/2018")
time.sleep(5)
inputElement.submit()

【讨论】:

  • 对不起@Lafa,我先尝试过这种方法。使用此方法,应用程序在程序发送 clear() 时崩溃。我收到内部服务器错误。
  • 表单上有提交按钮吗?您是否尝试过单击它而不是像当前那样在 inputElement 上执行提交操作?
  • 没有。那没有。看起来像这张图片dropbox.com/s/g97qzux4zy8c9lv/… 如果我手动操作,“Enter”按钮不起作用。我必须在窗口本身之外单击。
猜你喜欢
  • 1970-01-01
  • 2017-01-03
  • 1970-01-01
  • 2014-09-23
  • 2020-05-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-01-29
相关资源
最近更新 更多