【发布时间】:2016-06-05 12:13:23
【问题描述】:
我正在使用 Selenium Python 遍历一个行表。在 GUI 上,我从表中删除了一个项目。在我的脚本中,我正在检查该项目是否不存在以验证它是否已被删除。 当我遍历我的表时,它停在第一行。它不会持续到最后一行。
例如我将 Name 参数传递给我的方法。我想迭代整个行表,第 1 列并检查名称不存在。如果 Name 不存在,则返回 true。
我的代码 sn-p 是:
def is_data_objet_deleted(self, name):
# Params : name : the name of the data object, e.g. Name, Address, Phone, DOB
try:
#WebDriverWait(self.driver, 20).until(EC.presence_of_element_located((By.ID, 'data_configuration_data_objects_ct_fields_body')))
table_id = WebDriverWait(self.driver, 20).until(EC.presence_of_element_located((By.ID, 'data_configuration_data_objects_ct_fields_body')))
rows = table_id.find_elements(By.TAG_NAME, "tr")
for row in rows:
# Get the columns
col_name = row.find_elements(By.TAG_NAME, "td")[1] # This is the Checkbox column
col_name = row.find_elements(By.TAG_NAME, "td")[2] # This is the Name column
print "col_name.text = "
print col_name.text
if (col_name.text != name):
return True
#return False
except NoSuchElementException, e:
print "Element not found "
print e
self.save_screenshot("data_objects_page_saved_details")
return False
我的桌子停在第一行。 请帮忙, 谢谢, 里亚兹
【问题讨论】:
标签: python python-2.7 selenium selenium-webdriver