1      source = open("D:\\appium\\testdata\\username.txt", "r") #用户名文件
 2         un = source.readlines() #读取用户名
 3         source.close()
 4 
 5         source2 = open("D:\\appium\\testdata\\password.txt", "r") #用户名文件
 6         pw = source2.readlines() #读取密码
 7         source2.close()
 8         #智能等待10s
 9         #self.driver.implicitly_wait(10)
10         #登录操作
11         #WebDriverWait(driver,timeout).until(lambda driver: driver.find_element_by_id(idstr).is_displayed(), msg)
12         WebDriverWait(self.driver, 10).until(lambda driver: self.driver.find_element_by_id("com.jiudao.ccare:id/user_name").is_displayed())
13         username=self.driver.find_element_by_id("com.jiudao.ccare:id/user_name")
14         username.clear()
15         username.send_keys(un)
16         #self.assertEqual(un,username.get_attribute("text"),"username error")
17         #assertThat(username.get_attribute(),equalTo("node"));  
18         #self.assertEqual("suser@umser",username.get_attribute(),"username error")
19         password=self.driver.find_element_by_id("com.jiudao.ccare:id/user_password")
20         password.clear()
21         password.send_keys(pw)

 

缺点:
虽然目的达到了这,但这样的实现有很多问题:
1、用户名密码分别在不同的文件里,修改用户名和密码比较麻烦。
2、username.txt 和 password.txt 文件中只能保存一个用户密码,无能很好的循环读取。

相关文章:

  • 2021-11-22
  • 2021-11-17
  • 2021-09-21
  • 2021-12-10
  • 2022-01-18
  • 2021-12-10
  • 2021-12-03
猜你喜欢
  • 2021-06-25
  • 2021-09-03
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-10
  • 2022-01-07
相关资源
相似解决方案