142536a 发表于 2018-8-7 08:21:29

python+selenium UI脚本用例

path="E:/chromedriver.exe"  def __init__(self,url):
  self.url=url
  self.wd = webdriver.Chrome(self.path)
  def openBrowser(self):
  self.wd.get(self.url)
  self.wd.maximize_window()
  def closeBrowser(self):
  self.wd.quit()
  def findeleOrg(self):
  hospitals = self.wd.find_elements_by_css_selector("select>option")
  return hospitals
  def findeledept(self):
  hospitalDatatype = self.wd.find_elements_by_css_selector('select>option')
  return hospitalDatatype
  def deleteCords(self):
  while True:
  cords=self.wd.find_elements_by_css_selector("table tr>td:nth-of-type(8)>input")
  if len(cords)==0:
  break
  cords.click()
  time.sleep(1)    #定位元素前后要加等待时间,特别是刷新的页面
  def hospitalConfig(self):
  self.wd.find_element_by_partial_link_text(u"医院视图SQL").click()
  hospitals=self.findeleOrg()
  hospitalDatatype=self.findeledept()
  for num in range(len(hospitals)-1):
  hospitals = self.findeleOrg()
  hospitals.click()
  for numdata in range(len(hospitalDatatype)-1):
  hospitals = self.findeleOrg()
  hospitals.click()
  hospitalDatatype = self.findeledept()
  time.sleep(1)
  hospitalDatatype.click()
  time.sleep(2)
  self.wd.find_element_by_css_selector("input").click()
  self.wd.find_element_by_id("submit_id").click()
  self.wd.find_element_by_partial_link_text(u"医院视图SQL").click()
页: [1]
查看完整版本: python+selenium UI脚本用例