login.txt 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. package nju.edu.cn;
  2. //import io.appium.java_client.AndroidKeyCode;
  3. import io.appium.java_client.AppiumDriver;
  4. import io.appium.java_client.android.AndroidDriver;
  5. import org.apache.commons.io.FileUtils;
  6. import org.junit.After;
  7. import org.junit.Before;
  8. import org.junit.Test;
  9. import org.openqa.selenium.By;
  10. import org.openqa.selenium.OutputType;
  11. import org.openqa.selenium.TakesScreenshot;
  12. import org.openqa.selenium.WebElement;
  13. import org.openqa.selenium.remote.CapabilityType;
  14. import org.openqa.selenium.remote.DesiredCapabilities;
  15. import org.openqa.selenium.server.browserlaunchers.Sleeper;
  16. import com.sun.prism.Texture;
  17. import java.io.File;
  18. import java.io.IOException;
  19. import java.net.URL;
  20. import java.sql.Time;
  21. import java.util.List;
  22. public class SecondTest {
  23. private AndroidDriver driver;
  24. @Before
  25. public void setUp() throws Exception {
  26. File classpathRoot = new File(System.getProperty("user.dir"));
  27. File appDir = new File(classpathRoot, "apps");
  28. File app = new File(appDir, "UpocStudent.apk");
  29. DesiredCapabilities capabilities = new DesiredCapabilities();
  30. capabilities.setCapability("browserName", "");
  31. capabilities.setCapability("platformName", "Android");
  32. capabilities.setCapability("deviceName", "Android Emulator");
  33. capabilities.setCapability("newCommandTimeout", 10);
  34. capabilities.setCapability("app", app.getAbsolutePath());
  35. capabilities.setCapability("appPackage", "com.xdf.ucan");
  36. capabilities.setCapability("appActivity", ".ui.login.StartActivity");
  37. driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
  38. }
  39. @Test
  40. public void addContact(){
  41. //UpocStudent
  42. WebElement el1 = driver.findElementById("com.xdf.ucan:id/editText1");
  43. el1.sendKeys("15861819028");
  44. WebElement el2 = driver.findElementById("com.xdf.ucan:id/editText2");
  45. el2.sendKeys("00zoosong");
  46. //Jlb
  47. WebElement el3 = driver.findElementById("com.yao.club:id/et_username");
  48. el3.sendKeys("张三");
  49. WebElement el4 = driver.findElementById("com.yao.club:id/et_pwd");
  50. el4.sendKeys("123");
  51. //Jchat
  52. WebElement el5 = driver.findElementById("io.jchat.android:id/login_userName");
  53. el5.sendKeys("1234567");
  54. WebElement el6 = driver.findElementById("io.jchat.android:id/login_passWord");
  55. el6.sendKeys("1234567");
  56. //GuDong
  57. WebElement el7 = driver.findElementById("android:id/input");
  58. el7.sendKeys("test");
  59. //Bilibili
  60. WebElement el8 = driver.findElementById("com.hotbitmapgg.ohmybilibili:id/et_username");
  61. el8.sendKeys("123");
  62. WebElement el9 = driver.findElementById("com.hotbitmapgg.ohmybilibili:id/et_password");
  63. el9.sendKeys("123");
  64. //Jianshi
  65. WebElement el10 = driver.findElementById("com.wingjay.android.jianshi:id/email");
  66. el10.sendKeys("test@demo.com");
  67. WebElement el11 = driver.findElementById("com.wingjay.android.jianshi:id/password");
  68. el11.sendKeys("test123");
  69. WebElement el12 = driver.findElementById("com.wingjay.android.jianshi:id/edit_title");
  70. el12.sendKeys("demo");
  71. WebElement el13 = driver.findElementById("com.wingjay.android.jianshi:id/edit_content");
  72. el13.sendKeys("Hello World!");
  73. }
  74. @After
  75. public void tearDown() throws Exception {
  76. driver.quit();
  77. }
  78. }