1

我正在尝试在http://matrix.itasoftware.com/上自动搜索,但在我打算使用的字段上定位元素时遇到了问题 - 网站使用的表单是通过 Javascript AFAIK 生成的。我被第一个字段难住了:在多城市选项卡下,在航班 1 下,在“出发地”字段上。

使用 Selenium IDE,我设法找到了这个特定字段的 ID ita_form_multislice_MultiSliceRow_0_origin:,但测试它会返回错误“NoSuchElementException”。

我的代码:

flight1_origin = driver.find_element_by_id("ita_form_multislice_MultiSliceRow_0_origin")

该网站通过 Javascript 生成表单,因此很难通过正常方式找到实际的 ID 和所有内容。有什么想法吗?

4

1 回答 1

0

My guess is that you are not on the tab. That element does not actually get appended to the DOM until the tab gets clicked.

Add this to your script before trying to find the departing from field.

driver.find_element_by_id("ita_layout_TabContainer_0_tablist_ita_form_multislice_MultiSliceForm_0").click()
于 2013-09-29T09:38:24.163 回答