使用selenium Python将值传递给文本框

时间:2018-03-28 01:23:38

标签: python selenium

我试图将Lat Long Value传递给文本框 但它的投掷错误。

以下是代码:

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.support.ui import Select
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import TimeoutException
import time

Lat_value = "50"
Long_value = "-125"

executable_path = "/usr/bin/chromedriver"
chrome_options = Options()
os.environ["webdriver.chrome.driver"] = executable_path
driver = webdriver.Chrome(executable_path=executable_path, chrome_options=chrome_options)
driver.get("http://windspeed.atcouncil.org/")
driver.maximize_window()
print driver.title
driver.find_element_by_xpath("""//*[@id="decimal"]""").click()  # click the radio button for Lat Long
driver.find_element_by_xpath("""//*[@id="latt"]""").click()
driver.find_element_by_xpath("""//*[@id="latt"]""").send_keys(Lat_value)
driver.find_element_by_xpath("""//*[@id="longt"]""").click()
driver.find_element_by_xpath("""//*[@id="longt"]""").send_keys(Long_value)
driver.find_element_by_xpath('//*[@id="searchform"]/div[1]/div[7]/span/input').click()
driver.close()

这是错误信息:

Traceback (most recent call last):
  File "wind_speed_Lat_Long.py", line 22, in <module>
    driver.find_element_by_xpath("""//*[@id="latt"]""").send_keys(Lat_value)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webelement.py", line 352, in send_keys
    'value': keys_to_typing(value)})
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webelement.py", line 501, in _execute
    return self._parent.execute(command, params)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 308, in execute
    self.error_handler.check_response(response)
  File "/usr/local/lib/python2.7/dist-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=65.0.3325.181)
  (Driver info: chromedriver=2.34.522913 (36222509aa6e819815938cbf2709b4849735537c),platform=Linux 4.13.0-37-generic x86_64)

0 个答案:

没有答案