Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x Python-Selenium无法按Eastleigh网站上的按钮_Python 3.x_Selenium - Fatal编程技术网

Python 3.x Python-Selenium无法按Eastleigh网站上的按钮

Python 3.x Python-Selenium无法按Eastleigh网站上的按钮,python-3.x,selenium,Python 3.x,Selenium,我用Selenium制作了一个脚本,应该可以访问Eastleigh网站,它在上周的日期中点击“高级”类型并按“搜索”所有这些作品,除了它没有按“搜索”按钮,为什么?网站中的name变量名为“submit”,这是我的代码所要查找的,但我得到一个错误: Traceback (most recent call last): File "C:\Users\Goten\Desktop\code\main.py", line 17, in <module> import urls.e

我用Selenium制作了一个脚本,应该可以访问Eastleigh网站,它在上周的日期中点击“高级”类型并按“搜索”所有这些作品,除了它没有按“搜索”按钮,为什么?网站中的name变量名为“submit”,这是我的代码所要查找的,但我得到一个错误:

Traceback (most recent call last):
  File "C:\Users\Goten\Desktop\code\main.py", line 17, in <module>
    import urls.eastleigh
  File "C:\Users\Goten\Desktop\code\urls\eastleigh.py", line 48, in <module>
    driver.find_element_by_name("submit").click()
  File "C:\Users\Goten\Anaconda3\lib\site-packages\selenium\webdriver\remote\webelement.py", line 80, in click
    self._execute(Command.CLICK_ELEMENT)
  File "C:\Users\Goten\Anaconda3\lib\site-packages\selenium\webdriver\remote\webelement.py", line 628, in _execute
    return self._parent.execute(command, params)
  File "C:\Users\Goten\Anaconda3\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 320, in execute
    self.error_handler.check_response(response)
  File "C:\Users\Goten\Anaconda3\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.ElementNotVisibleException: Message: element not visible
  (Session info: chrome=69.0.3497.100)
  (Driver info: chromedriver=2.41.578737 (49da6702b16031c40d63e5618de03a32ff6c197e),platform=Windows NT 10.0.16299 x86_64)

DOM中有两个带有name=“submit”的按钮标记。你的目标按钮是第二个。识别“搜索”按钮时,请尝试使用第二个索引

driver.find_element_by_xpath("(//button[@name='submit'])[2]")

我在脚本中没有看到任何ID。你确定你在正确的页面上吗?你给我们提供了正确的URL吗?你的341:0项目是高级搜索的id,这很好。。但你的728:0是为选择下拉列表而不是为任何日期选择器。你在说什么?从字面上说,每件事都做它需要做的。它只是不会点击搜索,如果你运行脚本,它会为你完成剩下的工作。非常感谢
driver.find_element_by_xpath("(//button[@name='submit'])[2]")