1,添加目录
创建目录: mkdir+文件名称,一层一层创建
赋予权限: chown -R ossuser:ossgroup + 文件相对目录
2,刷新界面
WebDriver driver = BasicAction.getDriver();
driver.navigate().refresh();
3,java.lang.OutOfMemoryError:Java heap space
1> Eclipse - Configuration - Arguments
2> -Xms1024m -Xmx1200m
4,重启某个服务
sh ipmc_adm -cmd stopapp -app +服务名称
sh ipmc_adm -cmd startapp -app +服务名称
5,设置时间
date --set = “07/07/06 10:19” (月/日/年 时:分:秒)
6,webtest执行超时
src/WebtestApp.properties文件加上超时设置
webtest.testcase.execution.timeout = **
7,元素在iframe里
WebDriver driver = BasicAction.getDriver().switchTo().frame(BasicAction.getDriver().findElement(by.id("inner-plat-page")));
driver.findElement(by.xpath(“//*[@id='server-input-configuration']”)).click();
8,包含中文
[@id='icon-fiter']/span/span[1][contains(text(),"过滤")]
[@id='icon-fiter' and contains(@title,'过滤')] // 选取id为icon-fiter,并且标题中包含有“过滤”的title元素
9,删除固定目录下的文件
1 public void fileIsExist_Delete(){ 2 3 File file = new File("C:\user\download"); 4 5 File[] files = file.listFiles(); 6 7 int i = 0; 8 9 boolean flag = false; 10 11 while(i<90){ 12 13 for(int index = 0; index<files.length; index++){ 14 15 if(files[index].getName().startWith("UI_ReliabilityTest_")){ 16 17 files[index].delete(); 18 19 flag = true; 20 21 break; 22 23 } 24 25 } 26 27 if(flag){ 28 29 logger.debug("找到文件"); 30 31 break; 32 33 } else{ 34 35 BasicAction.sleep(5); 36 37 i=i+5; 38 39 } 40 41 } 42 43 if(!flag){ 44 45 logger.debug("没找到文件"); 46 47 } 48 49 }
10,post接口,body需要传参
JSON.stringify({topoParas:{topoDtaUUid:[],topoDataType:[]}})
"{"topoParas":{"topoDtaUUid":[],"topoDataType":[]}}"
11, 解除安全加固
bash /opt/SEK/cmd/SetEnv.sh; // 切root解固
12,查看系统信息 uname -a
查看系统资源占用情况 df -h
13,远程读取文件,复制该文件后,重命名(连续在线采集用到,使用带时间戳命名)
1 DateFormat formater = new SimpleDateFormat("yyyyMMddhhmmss"); 2 3 long now = System.currentTimeMillis(); 4 5 Calendar calendar = Calendar.getInstance(); 6 7 calendar.setTimeInMillis(now); 8 String time = formatter.format(calendar.getTime()); 9 10 11 12 File dstFile = new File("\\10.187.43.240\PerfLog\Schedule_pfm_" + time + ".txt"); 13 14 if(!dstFile){ 15 16 dstFile.createNewfile(); 17 } 18 19 File srcFile = new File("\\10.187.43.240\PerfLog\Schedule_pfm_1.txt"); 20 21 copyFile(dstFile,srcFile); 22 23 public static void copyFile(File dstFile,File srcFile){ 24 25 InputStream instream = null; 26 27 OutputStream outstream = null; 28 try{ 29 30 outstream = new FileOutputstream(dstFile); 31 instream = new FileInputstream(srcFile); 32 byte b[] = new byte[1024]; 33 34 int n; 35 36 try{ 37 38 while((n=instream.read(b)) != -1){ 39 40 outstream.write(b,0,n); 41 } 42 43 }catch(IOException e){ 44 45 e.printStackTrace(); 46 47 } 48 49 }catch(IOException e){ 50 51 e.printStackTrace(); 52 53 } finally{ 54 55 try{ 56 57 outstream.flush(); 58 outstream.close(); 59 instream.close(); 60 }catch(Exception e2){ 61 62 e2.printStackTrace(); 63 } 64 65 } 66 67 }