• Selenium自动化获取Http报文信息并判断当前API状态


        public int loadingFinishedCount(WebDriver driver){
    LogEntries logs = driver.manage().logs().get("performance");
    // System.out.println(" List of log entries: ");
    int m=0;
    for(Iterator<LogEntry> it = logs.iterator(); it.hasNext();){
    LogEntry entry = it.next();
    try{
    JSONObject json = new JSONObject(entry.getMessage());
    JSONObject message = json.getJSONObject("message");
    // System.out.println(message);
    String method = message.getString("method");
    if(method!=null&&"Network.loadingFinished".equals(method)){
    ++m;
    }
    }catch (JSONException e){
    e.printStackTrace();
    }
    }
    return m;
    }

    public void pageLoadingFinished(WebDriver driver, int loadingFinishedCount){
    loadingFinishedCount(driver);
    // System.out.println(m);
    for(double i=0; i<=1000; i=i+0.1) {
    int n = loadingFinishedCount(driver);
    // System.out.println(n);
    if (n >=loadingFinishedCount) {
    break;
    }
    }
    }

    reference:https://stackoverflow.com/questions/6509628/how-to-get-http-response-code-using-selenium-webdriver-with-java
  • 相关阅读:
    蒟蒻的填坑计划
    现在的状态....
    date modify
    set source
    image source
    simple auth
    net
    bridge
    iptable
    namespace
  • 原文地址:https://www.cnblogs.com/sushome/p/8670561.html
Copyright © 2020-2023  润新知