Python:Selenium程序包能够自动单击按钮,但不能使用sendkeys属性

时间:2018-09-17 04:59:39

标签: python-3.x selenium selenium-webdriver selenium-chromedriver

我有一个脚本转到网页,然后单击一个按钮,效果很好,但是当它在特定输入空间中寻找css_selector时,sendkeys属性将无法工作。

Traceback (most recent call last):
  File "C:\JIRA_Portal_CSV\RALLYSJ.py", line 42, in <module>
    nameField.send_keys("smane")
  File "C:\Python35\lib\site-packages\selenium\webdriver\remote\webelement.py", line 349, in send_keys
'value': keys_to_typing(value)})
  File "C:\Python35\lib\site-packages\selenium\webdriver\remote\webelement.py", line 493, in _execute
    return self._parent.execute(command, params)
  File "C:\Python35\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 256, in execute self.error_handler.check_response(response)
  File "C:\Python35\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 194, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: call function result missing 'value'
  (Session info: chrome=68.0.3440.106)
  (Driver info: chromedriver=2.30.477700 (0057494ad8732195794a7b32078424f92a5fce41),platform=Windows NT 6.1.7601 SP1 x86_64)

下面是我的代码:

import webbrowser
from selenium import webdriver
import time
import os

chromeOptions = webdriver.ChromeOptions()
br=webdriver.Chrome('C:/Python35/Scripts/chromedriver.exe',chrome_options=chromeOptions)


br.get('https:localxxx.rallydev.com')
time.sleep(2)
issue=br.find_element_by_css_selector('#AlternateAccountDiv > a')
issue.click()
time.sleep(2)
nameField =br.find_element_by_xpath("//[@id='UserID']")
nameField.send_keys("smane")

任何人都可以分享我的想法吗?

0 个答案:

没有答案