博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
使用WebDriver完成web页面切换操作(附源码)
阅读量:2200 次
发布时间:2019-05-03

本文共 692 字,大约阅读时间需要 2 分钟。

资源推荐:

视频资源: 

社区资源: 

public void testBaidu() throws Exception {

    driver.get("http://www.baidu.com");

    String parentID = driver.getWindowHandle(); //save current windowHandle
    driver.findElement(By.linkText("新 闻")).click();
    Set<String> allID = driver.getWindowHandles(); //save all opened windowHandle
    if(allID.remove(parentID)){ //remove the first windowhandle
    System.out.println("remove the first windowHandle success");
    }
    Iterator<String> iter = allID.iterator();
    while(iter.hasNext()){
    driver.switchTo().window(iter.next());//swith to the second handle
    driver.getCurrentUrl();
    }
    driver.findElement(By.linkText("总政治部副主任吴昌德等6人晋升上将")).click();
    Thread.sleep(5000);
    System.out.println("it's over");
  }

转载地址:http://ojrub.baihongyu.com/

你可能感兴趣的文章
Bagging 简述
查看>>
详解 Stacking 的 python 实现
查看>>
简述极大似然估计
查看>>
用线性判别分析 LDA 降维
查看>>
用 Doc2Vec 得到文档/段落/句子的向量表达
查看>>
使聊天机器人具有个性
查看>>
使聊天机器人的对话更有营养
查看>>
一个 tflearn 情感分析小例子
查看>>
attention 机制入门
查看>>
手把手用 IntelliJ IDEA 和 SBT 创建 scala 项目
查看>>
GAN 的 keras 实现
查看>>
AI 在 marketing 上的应用
查看>>
Logistic regression 为什么用 sigmoid ?
查看>>
Logistic Regression 为什么用极大似然函数
查看>>
SVM 的核函数选择和调参
查看>>
LightGBM 如何调参
查看>>
用 TensorFlow.js 在浏览器中训练神经网络
查看>>
cs230 深度学习 Lecture 2 编程作业: Logistic Regression with a Neural Network mindset
查看>>
梯度消失问题与如何选择激活函数
查看>>
为什么需要 Mini-batch 梯度下降,及 TensorFlow 应用举例
查看>>