【发布时间】:2019-05-05 12:42:13
【问题描述】:
我一直在尝试定位到以下元素:
<input type="text" ng-change="vm.refreshTimeline()" button-enter="vm.filterRowChange();" ng-model="vm.filterRowValue" class="ng-pristine ng-untouched ng-valid ng-empty">
它是一个搜索框。
我尝试使用类名、xpath、css 选择器,但这些都不起作用。我仍然收到带有相应属性的“无法找到元素”。
driver.find_element_by_css_selector('body > div:nth-child(1) > div.uiview.ng-scope > div.container.asset-details.ng-scope > div.row.top-buffer > div > div.GanttController > div.input-append.text-center.search_section.ng-scope > input')
driver.find_element_by_class_name('ng-pristine ng-untouched ng-valid ng-empty')
find_element_by_xpath('/html/body/div[1]/div[2]/div[1]/div[4]/div/div[2]/div[1]/input')
find_element_by_link_text('Search by Equipment ID or S/N')
我什至尝试使用 xpath helper 来找出确切的 xpath,但它显示错误:
[INVALID XPATH EXPRESSION]
帮我解决这个问题。
提前致谢。
【问题讨论】:
-
试试
find_element_by_xpath("""/html/body/div[1]/div[2]/div[1]/div[4]/div/div[2]/div[1]/input""")
标签: python selenium-webdriver xpath css-selectors webdriverwait