获取页面的Title属性

  被测网址http:http://www.baidu.com

  Java语言版本的API实例代码

  String url = "http://www.baidu.com";
  @Test
  public void getTitle() {
    driver.manage().window().maximize();
    driver.navigate().to(url);
    String title = driver.getTitle();
    System.out.println(title);
    Assert.assertEquals("百度一下,你就知道", title);
}

  获取页面的源代码

  被测网址http:http://www.sogou.com

  Java语言版本的API实例代码

  String url = "http://www.sogou.com";
  @Test
  public void getCurrentPageUrl() {
    driver.manage().window().maximize();
    driver.navigate().to(url);
    String pageSource = driver.getPageSource();
    System.out.println(pageSource);
    //断言判断页面源代码中是否包含购物两个字,判断页面是否正确
    Assert.assertTrue(pageSource.contains("购物"));
}

  清除输入框中的内容

  被测网址http:http://www.baidu.com

  Java语言版本的API实例代码

  @Test
  public void clearInputBoxtext() throws InterruptedException {
    WebElement input = driver.findElement(By.id("kw"));
    input.clear(); //清除输入框kw中的文本
    try {
    Thread.sleep(3000);
    } catch (Exception e) {
    // TODO: handle exception
    e.printStackTrace();
}
}

  在输入框中输入指定内容

  被测网址http:http://www.baidu.com

  Java语言版本的API实例代码

  @Test
  public void clearInputBoxtext()  {
    //在输入框中输入seleinum

    driver.findElement(By.id("kw")).sendKeys("seleinum");
}

WebDriverAPI(3)的更多相关文章

  1. WebDriverAPI(7)

      查看页面元素的属性 测试网址 http://www.baidu.com Java语言版本API实例 @Test public void getWebElementAttribute() { dri ...

  2. WebDriverAPI(10)

    操作Frame页面元素 测试网址代码 frameset.html: <html> <head> <title>frameset页面</title> &l ...

  3. WebDriverAPI(9)

    操作JavaScript的Alert窗口 测试网址代码 <html> <head> <title>你喜欢的水果</title> </head> ...

  4. WebDriverAPI(4)

    单击某个元素 采用元素id.click()方法即可 双击某个元素id.doubleClick 操作单选下拉列表 测试网页HTML代码 <html> <body> <sel ...

  5. WebDriverAPI(2)

    操作浏览器窗口 被测网址http:http://www.baidu.com Java语言版本的API实例代码 String url = "http://www.baidu.com" ...

  6. WebDriverAPI(8)

    判断页面元素是否存在 测试网址 http://www.baidu.com Java语言版本API实例 @Test public void testIsElementPresent(){ driver. ...

  7. WebDriverAPI(6)

    在指定元素上方进行鼠标悬浮 测试网址 http://www.baidu.com Java语言版本实例 @Test public void roverOnElement() { driver.manag ...

  8. WebDriverAPI(5)

    将当前浏览器截屏 测试网址 http://www.baidu.com Java语言版本实例 @Test public void captureScreenInCurrentWindows() { dr ...

  9. WebDriverAPI(1)

    访问某网页地址 被测网址http:http://www.baidu.com Java语言版本的API实例代码 方法一: @Test public void visitURL(){ String bas ...

随机推荐

  1. $.fn.extend 和$.extend函数

    区别和详解:jQuery extend()和jQuery.fn.extend()     首先是简单的概述区别:$.extend()是类方法   $.fn.extend()是原型方法   对象方法和原 ...

  2. 构造函数constructor 与析构函数destructor(一)

    构造函数定义:构造函数c++中在创建对象时自动调用,用来初始化对象的特殊函数. (1)构造函数的名字必须与类的名字相同,不能有返回值,哪怕是void 也不行. (2)通常情况下构造函数应声明为公有函数 ...

  3. 做SEO都需要具备哪些方面的知识

    做seo需要了解的基本知识有利于seo工作的进行 一.了解搜索引擎的工作原理 搜索引擎的基本工作原理包括如下三个过程: 1.首先在互联网中发现.搜集网页信息; 2.同时对信息进行提取和组织建立索引库; ...

  4. 2018.10.20 bzoj2748: [HAOI2012]音量调节(背包)

    传送门 这题是不是太sbsbsb了一点. 难度直逼普及-. 直接背包判存在性就行了. 代码: #include<bits/stdc++.h> using namespace std; bo ...

  5. foreach循环赋值问题

    foreach ($list as $key=>$val){ $data=array();//这一个一定要加上不然循环后,modify_one,modify_two都会赋值 if ($val[' ...

  6. python 取整itertools

    #coding:utf-8 import sys import itertools def MaxString(n,nums): list1 = nums list2 = [] for i in ra ...

  7. Spring3.x错误---- Cannot proxy target class because CGLIB2 is not available. Add CGLIB to the class path or specify proxy interfaces.

    Spring3.x错误: 解决方法: 缺少cglib的包, 下载地址: http://sourceforge.net/projects/cglib/files/latest/download?sour ...

  8. 功能强大的文件上传插件带上传进度-WebUploader

    WebUploader是由Baidu WebFE(FEX)团队开发的一个以HTML5/FLASH构建的现代文件上传组件.在现代的浏览器里面能充分发挥HTML5的优势,同时又不摒弃主流IE浏览器,沿用老 ...

  9. 解决Error creating bean with name 'huayuanjingguanDaoimp' defined in file [D:\apache-tomcat-7.0.52\webapps\landscapings\WEB-INF\classes\com\itheima\landscaping\dao\imp\huayuanjingguanDaoimp.class]: Invo

    问题描述: 10:23:13,585 ERROR ContextLoader:307 - Context initialization failedorg.springframework.beans. ...

  10. hdu 4952 暴力

    http://acm.hdu.edu.cn/showproblem.php?pid=4952 给定x,k,i从1到k,每次a[i]要是i的倍数,并且a[i]大于等于a[i-1],x为a0 递推到下一个 ...