2018-12-17

2018-12-17  本文已影响0人  雁_9587
@Test
  public void test() {
    //打开网址
    driver.get("http://www.guoyasoft.com:8080/guoya-client-qa/");
    //定位元素
    driver.findElement(By.xpath("//a[contains (text(),'面试统计')]")).click();
    sleep(2);
    //定位Iframe框
    WebElement iframe = driver.findElement(By.xpath("//iframe"));
    //切换到iframe框
    driver.switchTo().frame(iframe);
    //操作iframe框里的元素
    driver.findElement(By.xpath("//input[@value=\"查询\"]")).click();
    sleep(2);
    //窗口切换出iframe框
    driver.switchTo().defaultContent();
    //定位元素并操作
    driver.findElement(By.xpath("//a[text()='查询面试']")).click();
    sleep(2);
  }
image.png
 @Test
  public void testFor() {
    //int类型的数组,变量名arr,存1, 2, 3, 4, 5, 6, 7, 8, 9, 10的值
    int[] arr = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
    for (int i = 0; i <= arr.length - 1; i++) {
      System.out.println(arr[i]);
    }
    for (int i :
        arr) {
      System.out.println(i);
    }
    for (int i : arr) {
      System.out.println(i);
  }
    Map<String,String>map=new HashMap<String,String>();
    map.put("姓名","席怡雪");
    map.put("年龄","18");
    map.put("性别","女");
    for (String key:map.keySet()) {
      System.out.println(map.get(key));
    }
    }
image.png image.png
@Test
  public void jiuJiu() {
  // 循环9行
  for (int i = 1; i <= 9; i++) {
    // 每行循环不超过行号的次数
    for (int j = 1; j <= i; j++) {
      // 输出一个乘法式
      System.out.print(j + "x" + i + "=" + i * j + "\t");
    }
    // 换行
    System.out.println();
  }
image.png
}
    @Test
     public void testIfbuy() {
      int yuE = 200;
      int yuEBao = 3000;
      int yinHangka = 20000;
      int buy = 2000;
      if (yuE >= buy) {
        System.out.println("余额扣除" + buy);
      } else if (yuEBao >= buy) {
        System.out.println("余额宝扣除" + buy);
      } else if (yinHangka >= buy) {
        System.out.println("银行卡扣除" + buy);
      } else {
        System.out.println("扣款失败");
      }
    }
image.png
@Test
        public void testBubblesort(){
          int[] arr={17,21,14,32,8,19};
          for (int i:arr) {
            System.out.print(i+"\t");
          }
          System.out.println();
         for (int i=arr.length-1;i>=1;i--){
           for (int j=0;j<=i-1;j++){
             if (arr [j]>arr[j+1]){
               int a=arr[j];
               arr[j]=arr[j+1];
               arr[j+1]=a;
             }
           }
         }
        for (int i:arr) {
          System.out.print(i+"\t");
      }
        System.out.println();
}
}
image.png

冒泡排序

冒泡算法

上一篇下一篇

猜你喜欢

热点阅读