Excel 读写相关
https://testerhome.com/topics/14247
import openpyxl
from appium import webdriver
import time, selenium
wb = openpyxl.load_workbook("bdd.xlsx", data_only=True)
wb.guess_types = True
sh = wb['工作表 1']
caps = {}
caps["bundleId"] = "com.example.apple-samplecode.UICatalog"
driver = webdriver.Remote("http://127.0.0.1:8100/wd/hub", caps)
def wait_element(xpath,timeout=30):
deadline=time.time()+timeout
while time.time() < deadline:
try:
el=driver.find_element_by_xpath(xpath)
return el
except selenium.common.exceptions.NoSuchElementException:
time.sleep(.2)
raise RuntimeError("NoSuchElementException in wait_element")
for row in sh.rows:
if row[0].value not in ['CLICK', 'ASSERT']:
continue
print(row[0].value, row[1].value)
op = row[0].value
xpath = row[1].value
if op == 'CLICK':
wait_element(xpath).click()
if op == 'ASSERT':
wait_element(xpath)