我正在使用selenium和莴苣进行python测试。 我有这个步骤来计算employee表的行数
@step('I count employee table rows')
def i_count_emp_table_rows(step):
try:
elems = world.driver.find_elements_by_xpath(".//*[@id='myTable']/tr")
sum = 0
for item in elems:
sum= sum+1
return sum
except Exception, e:
print e
return None
我还有另外一个步骤,在这一步中,我想保存雇员表中的雇员人数(使用上面的步骤),然后单击“添加雇员”按钮进入下一页。你知道吗
@step('I click the Add Employee Button')
def i_click_the_add_employee_button(step):
world.prev_no_of_emp = step.given('I count employee table rows')
print "Right Now total rows in table: " + str(world.pre_no_of_emp)
done, world.driver = click_page_element(admin_add_employee_button_xpath, world.driver, wait=10)
但有趣的是,我总是得到“真”而不是列表计数。我甚至用了len()但是没有成功
这是打印报表的结果。
当前表中的总行数:True
您需要将计数放入某个全局变量中。见以下更新步骤。你知道吗
相关问题 更多 >
编程相关推荐