【发布时间】:2018-11-13 17:53:39
【问题描述】:
我正在尝试使用 Selenium 遍历表中的一堆行,但我发现在尝试这样做时出现错误。代码应该循环并捕获变量中的每一行,然后将其与我的引用变量进行比较,但它会抛出一个错误,表明我添加了一个无效或非法的选择器。
请在下面找到我的代码:
for record in range(35, 2, -1):
current_record = self.browser.find_element_by_css_selector('#web-body > div > div _
> div > div > div > div > _
div:nth-child(2) > div > div > div > div > div > div:nth-child(2) _
> div.FieldLayout---input_below > div > _
div.PagingGridLayout---scrollable_content > table _
> tbody > tr:nth-child(record) > td:nth-child(2) > div > p > a')
print('the current record is: ' + current_record.text)
#print the current record for debugging purposes
if self.entry_test_id != current_record.text:
continue
#if the current record in the loop != the correct record, go to the next record
else:
web_was_record_found = True #note that record was found for next check
actions.key_down(Keys.SHIFT).click(current_record).key_up(Keys.SHIFT).perform()
#open the found record in a new WINDOW
【问题讨论】:
-
下划线
_是什么意思?
标签: python selenium selenium-webdriver css-selectors