zoukankan      html  css  js  c++  java
  • java程序写的模拟用户点击的程序(抢小米程序)

    首先我先说明一下 我这个用的是Selenium(先说下原理 免得大家不懂什么意思 懂得就飞过吧!有的词是copy的 其他人的说法的!) 
    Selenium RC主要由两部分组成 
    第一个是Selenium Server 
    第二个是Client    Libraries 

    Selenium Server 是用于控制浏览器行为,总的来说,Selenium Server主要包括3个部分:Launcher, Http Proxy, Selenium Core。其中Selenium Core是被Selenium Server嵌入到浏览器页面中的。其实Selenium Core就是一堆JS函数的集合,就是通过这些JS函数,我们才可以实现用程序对浏览器进行操作。 

    Client Libraries是用来写测试案例时用来控制Selenium Server的库 

    public class XiaoMiAutoMain {
    public static void main(String[] args) {
    String baseUrl = "http://www.xiaomi.com/";
    WebDriver driver = new InternetExplorerDriver();
    WebElement element = null;
    while(true){
    try {
    driver.get(baseUrl);
    //Thread.sleep(30 * 1000);
    element = driver.findElement(By.className("btnorder"));
    element.click();
    if(driver.getCurrentUrl()!="http://t.hd.xiaomi.com/index.php?_a=20121119_m22_m1s7&_op=choose"){break;}
    } catch (Exception ex) {
    ex.printStackTrace();
    try {
    Thread.sleep(2 * 60 * 1000);
    } catch (InterruptedException e) {
    e.printStackTrace();
    }
    }
    }
    }

  • 相关阅读:
    [BZOJ2431] [HAOI2009]逆序对数列
    [Luogu2323] [HNOI2006]公路修建问题
    [Luogu2455] [SDOI2006]线性方程组
    [BZOJ3550] [Sdoi2014]数数
    [Noip2017] 列队
    [Luogu2824] [HEOI2016/TJOI2016]排序
    [BZOJ1060] [ZJOI2007]时态同步
    P1036 选数 题解
    快速幂取模算法详解
    同余定理及其应用
  • 原文地址:https://www.cnblogs.com/xuzhenmin/p/3284380.html
Copyright © 2011-2022 走看看