在.EXE中的webdriver公共密钥部分中使用硒库

时间:2019-07-03 15:18:50

标签: python selenium selenium-webdriver selenium-chromedriver pyinstaller

我一直在尝试使用selenium库在pyinstaller中创建一个.EXE,但是它已经使我成为可执行文件和所有内容,但是由于在webdriver.common.keys应该包含的部分中,它并未加载所有selenium库。工作,它什么都不执行

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import os, sys, inspect 
current_folder = os.path.realpath(os.path.abspath(os.path.split(inspect.getfile(inspect.currentframe() ))[0]))

def init_driver():
    chromedriver = os.path.join(current_folder,"chromedriver-Windows")
    # via this way, you explicitly let Chrome know where to find 
    # the webdriver.
    driver = webdriver.Chrome(executable_path = chromedriver)
    return driver

driver = init_driver()

driver.get("https://es.wikipedia.org/wiki/Wikipedia:Portada")
driver.find_element_by_id("searchInput").send_keys("tuna")
driver.find_element_by_id("searchInput").send_keys(Keys.RETURN)

错误的输出是

Traceback (most recent call last):
  File "C:\Users\taylor19\Desktop\robot\soi\prueba_soi1.py", line 26, in <module>
    driver.find_element_by_id("searchInput").send_keys("tuna")
  File "C:\pyton\lib\site-packages\selenium\webdriver\remote\webelement.py", line 479, in send_keys
    'value': keys_to_typing(value)})
  File "C:\pyton\lib\site-packages\selenium\webdriver\remote\webelement.py", line 633, in _execute
    return self._parent.execute(command, params)
  File "C:\pyton\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "C:\pyton\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: call function result missing 'value'
  (Session info: chrome=75.0.3770.100)
  (Driver info: chromedriver=2.24.417431 (9aea000394714d2fbb20850021f6204f2256b9cf),platform=Windows NT 10.0.17134 x86_64)

0 个答案:

没有答案