zoukankan      html  css  js  c++  java
  • 慕测的自主可控测试

    最近准备自主可控测试比赛,要求用360浏览器。

     1 import java.util.ArrayList;
     2 import java.util.List;
     3 import java.util.Set;
     4 
     5 import org.openqa.selenium.chrome.ChromeDriver;
     6 import org.openqa.selenium.chrome.ChromeOptions;
     7 import org.openqa.selenium.firefox.FirefoxBinary;
     8 import org.openqa.selenium.firefox.FirefoxDriver;
     9 import org.openqa.selenium.WebDriver;
    10 import org.openqa.selenium.WebElement;
    11 import org.openqa.selenium.By;
    12 public class Example {
    13 
    14     // Mooctest Selenium Example
    15 
    16 
    17     // <!> Check if selenium-standalone.jar is added to build path.
    18 
    19     public static void test(WebDriver driver)   {
    20          try {
    21             driver.get("http://114.116.106.156/show-how/common/login.jsp");     
    22             Thread.sleep(2000);
    23             //登陆
    24             driver.findElement(By.xpath("//*[@id="username"]")).sendKeys("test006");
    25             driver.findElement(By.xpath("//*[@id="password"]")).sendKeys("1");                
    26             driver.findElement(By.xpath("//*[@id="userForm"]/div[1]/div[4]/button")).click();
    27             Thread.sleep(1000);
    28             //修改个人信息
    29             driver.findElement(By.xpath("//*[@id="main-menu"]/li[2]/a")).click();
    30             Thread.sleep(1000);
    31             driver.findElement(By.xpath("//*[@id="main-menu"]/li[2]/ul/li[1]/a")).click();
    32             Thread.sleep(1000);
    33             driver.findElement(By.xpath("//*[@id="main-menu"]/li[2]/ul/li[1]/ul/li[1]/a")).click();
    34             Thread.sleep(1000);
    35             //修改维护信息
    36             driver.findElement(By.xpath("//*[@id="pimInfo_email"]")).clear();
    37             Thread.sleep(1000);
    38             driver.findElement(By.xpath("//*[@id="pimInfo_email"]")).sendKeys("123456@163.com");
    39             Thread.sleep(1000);
    40             driver.findElement(By.xpath("//*[@id="pimInfo_cellphone"]")).clear();
    41             Thread.sleep(1000);
    42             driver.findElement(By.xpath("//*[@id="pimInfo_cellphone"]")).sendKeys("12345678901");
    43             Thread.sleep(1000);
    44             driver.findElement(By.xpath("//*[@id="submitButton"]")).click();
    45             Thread.sleep(5000);
    46             //退出浏览器
    47             driver.quit();              
    48             
    49         } catch (Exception e) {
    50             // TODO: handle exception
    51         }           
    52         
    53     }
    54     public static void main(String[] args) {
    55         // Run main function to test your script.      
    56     //用火狐浏览器打开
    57    //    FirefoxDriver driver = new FirefoxDriver();     
    58         
    59         System.setProperty("webdriver.chrome.driver","E:\360searech\360Chrome\Chrome\Application\chromedriver.exe");
    60         String  browser_url= "E:\360searech\360Chrome\Chrome\Application\360chrome.exe";
    61         ChromeOptions options = new ChromeOptions();
    62         options.setBinary(browser_url); 
    63         WebDriver driver =  new ChromeDriver(options );
    64      
    65         try { test(driver); } 
    66         catch(Exception e) { e.printStackTrace(); }
    67       //  finally { driver.quit(); }
    68     }
    69 }
  • 相关阅读:
    再谈后兵 FileInfo 与 DirectoryInfo类 清晰的winform界面(技术改变世界cnblog)
    在.NET Core中使用Channel(二)
    C#中的依赖注入和IoC容器
    改进你的c#代码的5个技巧(一)
    将WCF迁移到gRPC
    在.NET Core中使用Channel(三)
    在.NET Core中使用Channel(一)
    .NET 5 源代码生成器——MediatR——CQRS
    在大型软件项目中如何处理错误和异常
    在 ASP.NET Core和Worker Service中使用Quartz.Net
  • 原文地址:https://www.cnblogs.com/tianqianlan/p/11660593.html
Copyright © 2011-2022 走看看