def get_table_content(self, driver, value_num): arr = [] arr1 = [] try: # 按行查询表格的数据,取出的数据是一整行,按空格分隔每一列的数据 table_tr_list = driver.find_element(*self.table_loc).find_elements(By.TAG_NAME, "tr") time.sleep(5) for tr in table_tr_list: # result = unicode(tr.text, 'GBK').encode('UTF-8') arr1 = (tr.text).split(" ") # 以空格拆分成若干个(个数与列的个数相同)一维列表 arr.append(arr1) # 将表格数据组成二维的列表 except Exception as e: print(e) # 循环遍历table数据,确定查询数据的位置 for i in range(len(arr)): tip_num = value_num[i] for j in range(len(arr[i])): print(arr[i][j]) input_xpath = (By.XPATH, '//*[@id="390dd8f4-8405-4f64-a260-230a0e54b619-non-body"]/tbody/tr[j]/td[i+1]/input') BasePage.text_sender(self, input_xpath, tip_num[j]) time.sleep(5)
def waybill_send(self, waybill): BasePage.text_sender(self, self.waybillNo_loc, waybill)