|
@@ -1,52 +1,68 @@
|
|
|
package net.mooctest.www.android_auto_test.common;
|
|
|
|
|
|
-import com.aliyun.oss.OSSClient;
|
|
|
-import com.aliyun.oss.model.ListObjectsRequest;
|
|
|
-import com.aliyun.oss.model.OSSObjectSummary;
|
|
|
-import com.aliyun.oss.model.ObjectListing;
|
|
|
-import org.apache.poi.hssf.usermodel.HSSFRow;
|
|
|
-import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
-import org.apache.poi.ss.usermodel.Sheet;
|
|
|
-import org.apache.poi.ss.usermodel.Workbook;
|
|
|
+import com.sun.tools.javac.Main;
|
|
|
|
|
|
-import java.io.FileOutputStream;
|
|
|
+import java.io.File;
|
|
|
+import java.lang.reflect.Method;
|
|
|
+import java.net.MalformedURLException;
|
|
|
+import java.net.URL;
|
|
|
+
|
|
|
+import io.appium.java_client.AppiumDriver;
|
|
|
+import io.appium.java_client.android.AndroidDriver;
|
|
|
+import net.mooctest.www.android_auto_test.common.constant.Consts;
|
|
|
+import net.mooctest.www.android_auto_test.common.exceptions.AppiumDriverInitException;
|
|
|
+import net.mooctest.www.android_auto_test.utils.DeviceUtil;
|
|
|
+import net.mooctest.www.android_auto_test.utils.PrintUtil;
|
|
|
+import org.openqa.selenium.WebDriverException;
|
|
|
+import org.openqa.selenium.remote.CapabilityType;
|
|
|
+import org.openqa.selenium.remote.DesiredCapabilities;
|
|
|
+import org.openqa.selenium.remote.UnreachableBrowserException;
|
|
|
+
|
|
|
+import javax.tools.JavaCompiler;
|
|
|
+import javax.tools.ToolProvider;
|
|
|
|
|
|
public class FuckingTest {
|
|
|
public static void main(String args[]){
|
|
|
- String accessKeyId = "IvS323TIcWUT57MG";
|
|
|
- String endPoint = "http://oss-cn-hangzhou.aliyuncs.com";
|
|
|
- String accessKeySecret = "dYml7rvT8stQkoSjMYlfRTxNj9dEsI";
|
|
|
- String bucketName = "mooctest-share";
|
|
|
- OSSClient client = new OSSClient(endPoint, accessKeyId, accessKeySecret);
|
|
|
- ObjectListing list = client.listObjects(new ListObjectsRequest(bucketName)
|
|
|
- .withPrefix("mooctest-accept-test-dataset/APP扫描")
|
|
|
- .withMaxKeys(1000));
|
|
|
- Workbook wb = new HSSFWorkbook();
|
|
|
- Sheet sheet1 = wb.createSheet("APKS");
|
|
|
- String path = "/Users/henrylee/Desktop/text.xls";
|
|
|
- int index = 1;
|
|
|
- for (int i=0;i<list.getObjectSummaries().size();++i) {
|
|
|
- OSSObjectSummary ossObjectSummary = list.getObjectSummaries().get(i);
|
|
|
- String name = ossObjectSummary.getKey();
|
|
|
- if (!name.endsWith(".apk")){
|
|
|
- continue;
|
|
|
- }
|
|
|
- String[] t = name.split("/");
|
|
|
- String n = t[t.length-1];
|
|
|
- HSSFRow row = (HSSFRow) sheet1.createRow(index);
|
|
|
- row.createCell(0).setCellValue(index);
|
|
|
- row.createCell(1).setCellValue(n);
|
|
|
- row.createCell(4).setCellValue("http://mooctest-share.oss-cn-hangzhou.aliyuncs.com/" + name);
|
|
|
- index++;
|
|
|
+ JavaCompiler javac = ToolProvider.getSystemJavaCompiler();
|
|
|
+ int status = javac.run(null, null, null, "-d", "target/classes","scripts/Main.java");
|
|
|
+ if(status!=0){
|
|
|
+ System.out.println("没有编译成功!");
|
|
|
+ }
|
|
|
+
|
|
|
+ AppiumDriver d = initDriver();
|
|
|
+
|
|
|
+ try {
|
|
|
+ Class thisClass = Class.forName("ttt.Main");
|
|
|
+ Object iClass = thisClass.newInstance();
|
|
|
+ Method thisMethod = thisClass.getDeclaredMethod("test", AppiumDriver.class);
|
|
|
+ thisMethod.setAccessible(true);
|
|
|
+ thisMethod.invoke(iClass, d);
|
|
|
+ }
|
|
|
+ catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
}
|
|
|
- FileOutputStream outputStream = null;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static AppiumDriver initDriver(){
|
|
|
+ File app = new File("tasks/30000/趣头条_3.9.59.000.1231.1404.apk");
|
|
|
+ DesiredCapabilities capabilities = new DesiredCapabilities();
|
|
|
+ capabilities.setCapability(CapabilityType.BROWSER_NAME, "");
|
|
|
+ capabilities.setCapability("platformName", "Android");
|
|
|
+ capabilities.setCapability("deviceName", "Android Emulator");
|
|
|
+ capabilities.setCapability("platformVersion", "4.1.2");
|
|
|
+ capabilities.setCapability("app", app.getAbsolutePath());
|
|
|
+ capabilities.setCapability("appPackage", "com.jifen.qukan");
|
|
|
+ capabilities.setCapability("appActivity", "com.jifen.qkbase.main.MainActivity");
|
|
|
+ capabilities.setCapability("udid","66J5T19401004951");
|
|
|
+ capabilities.setCapability("unicodeKeyboard","true");
|
|
|
+ capabilities.setCapability("resetKeyboard","true");
|
|
|
+ capabilities.setCapability("noSign", "true");
|
|
|
+ AppiumDriver d = null;
|
|
|
try {
|
|
|
- outputStream = new FileOutputStream(path);
|
|
|
- wb.write(outputStream);
|
|
|
- outputStream.flush();
|
|
|
- outputStream.close();
|
|
|
- } catch (Exception e) {
|
|
|
+ d = new AndroidDriver(new URL("http://127.0.0.1:" + 8888 + "/wd/hub"), capabilities);
|
|
|
+ } catch (MalformedURLException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
+ return d;
|
|
|
}
|
|
|
}
|