使用splin测试机票搜索webform

2024-06-08 14:24:03 发布

您现在位置:Python中文网/ 问答频道 /正文

Im'正在测试http://www.go2see.ru上的票证搜索表单,试图访问它的元素:按钮、字段。 我需要填写第二个文本字段“目的地”。 我使用以下代码,得到了以下异常:

from splinter import Browser

browser = Browser()

# Fill in the url
browser.visit('http://www.go2see.ru')

#find and fill 2-nd text field (Destination), right of two air planes 
browser.find_by_id('avia-to').first.find_by_tag('input').fill('Moscow') 

File "/home/ada015/search_form_testing.py", line 9, in <module>
  browser.find_by_id('avia-to').first.find_by_tag('input').fill('Moscow')
File "/usr/local/lib/python2.7/dist-packages/splinter/element_list.py", line 75, in __getattr__
  self.__class__.__name__, name))

AttributeError: 'ElementList' object has no attribute 'fill'

Tags: toinbrowseridhttpbywwwru