• 慕测的自主可控测试


    最近准备自主可控测试比赛,要求用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 }
  • 相关阅读:
    Python 面向对象4-特殊成员
    Python 面向对象3-成员修饰符
    Python 面向对象2
    Python 面向对象
    Python hashlib模块
    使用Access-Control-Allow-Origin解决跨域
    倒计时
    移动端之touch事件--手指的滑动事件
    HTML5获取地理经纬度并通过百度接口得到实时位置
    h5直播
  • 原文地址:https://www.cnblogs.com/tianqianlan/p/11660593.html
Copyright © 2020-2023  润新知