zoukankan      html  css  js  c++  java
  • LAB02:Selenium的安装与使用

    1.安装

    首先点击火狐浏览器右上角选择添加附件:

    搜索

    选择安装:

    完成并启动:

    2.使用录制与导出功能:

     

    点击文件进行测试用例的输出:

    3.测试网站内容是否与所给的git地址相一致:

    首先,将三个java包导入到已经建立好的程序中;

    接下来编写代码使自动化测试能够完成:

     public void testUsecase() throws Exception {
    	  File csv = new File("inputgit.csv");  // CSV文件路径
    	    BufferedReader br = null;
    	    try
    	    {
    	        br = new BufferedReader(new FileReader(csv));
    	    } catch (FileNotFoundException e)
    	    {
    	        e.printStackTrace();
    	    }
    	    String line = "";
    	    String everyLine[];
    	    int i=1;
    	    try {
    	            while ((line = br.readLine()) != null)  //读取到的内容给line变量
    	            {
    	            	if(i==1){
    	            	i++;
    	            	continue;
    	            	}
    	            	else{
    	                everyLine = line.split(",");
    	                driver.get(baseUrl);
    	                driver.findElement(By.id("name")).clear();
    	                driver.findElement(By.id("name")).sendKeys(everyLine[0]);
    	                driver.findElement(By.id("pwd")).clear();
    	                driver.findElement(By.id("pwd")).sendKeys(everyLine[0].substring(4,10));
    	                driver.findElement(By.id("submit")).click();
    	  
    	               assertEquals(everyLine[2], driver.findElement(By.xpath("//tbody[@id='table-main']/tr[3]/td[2]")).getText());
    	               
    	                System.out.println(everyLine[1]+" is OK!");
    	            	}
    	            }  
    	    } catch (IOException e)
    	    {
    	        e.printStackTrace();
    	    }
      }
    

     首先从inputgit.csv文件中提取出同学的身份信息进行系统的登录。接下来将本地文件中的git地址链接与网页中的地址链接做对比判断是否一致。测试结果由于时间关系简单截取:

  • 相关阅读:
    loaded some nib but the view outlet was not set
    指标评比
    IOS DEVELOP FOR DUMMIES
    软件测试题二
    javascript select
    DOM节点类型详解
    mysql操作
    UVA 10055
    solutions for 'No Suitable Driver Found For Jdbc'
    解决git中文乱码问题
  • 原文地址:https://www.cnblogs.com/xuyuwei123/p/6610790.html
Copyright © 2011-2022 走看看