/*创建的类为junit class*/

package Selenium_lassen;

import static org.junit.Assert.*;

import java.io.File;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxBinary;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.remote.DesiredCapabilities;

public class Case2 {

WebDriver driver;
@Before
public void setUp() throws Exception {
//方法一
// System.setProperty("webdriver.firefox.bin", "D:\\ruanjian\\Firefox\\azml\\firefox.exe");
//方法二
// DesiredCapabilities capability=DesiredCapabilities.firefox();
// capability.setCapability("firefox_binary","D:\\ruanjian\\Firefox\\azml\\firefox.exe");
//driver = new FirefoxDriver(capability);
//方法三
File pathToFirefoxBinary = new File("D:\\ruanjian\\Firefox\\azml\\firefox.exe");
FirefoxBinary firefoxbin = new FirefoxBinary(pathToFirefoxBinary);
driver = new FirefoxDriver(firefoxbin,null);
}

@Test
public void test() throws Exception{
driver.get("http://www.google.com.hk");
WebElement element = driver.findElement(By.name("q"));
element.sendKeys("hello Selenium!");
element.submit();
}

@After
public void tearDown() throws Exception {
System.out.println("Page title is:"+driver.getTitle());
driver.quit();
}

}

【cl】selenium实例2:打开百度,输入hello world的更多相关文章

  1. python selenium启动浏览器打开百度搜索

    python selenium打开百度搜索 #!usr/bin/python from selenium import webdriver import time browser = webdrive ...

  2. 【cl】selenium实例一:打开百度,获取第四个标题

    /*创建类的时候是TestNG Class*/ package Selenium_lassen; import static org.junit.Assert.*; import java.util. ...

  3. selenium基础-打开百度进行搜索

    1. 安装Python 2. 安装selenium 3. 下载谷歌驱动ChromeDriver,放到Python的Scripts目录下 4. 编写代码,如下 # coding: utf-8 from ...

  4. selenium实例:unittest框架+PO开发模式

    这是<selenium2+python学习总结>的升级版. 1.         项目结构 2.         项目代码 1)         globalparameter.py # ...

  5. Python+Selenium基础篇-打开和关闭火狐浏览器

    本节介绍如何初始化一个webdriver实例对象driver,然后打开和关闭firefox浏览器.要用selenium打开fiefox浏览器.首先需要去下载一个driver插件geckodriver. ...

  6. Selenium2学习-009-WebUI自动化实战实例-007-Selenium 8种元素定位实战实例源代码(百度首页搜索录入框及登录链接)

    此 文主要讲述用 Java 编写 Selenium 自动化测试脚本编写过程中,通过 ID.name.xpath.cssSelector.linkText.className.partialLinkTe ...

  7. Selenium2+python自动化34-获取百度输入联想词

    前言 最近有小伙伴问百度输入后,输入框下方的联想词如何定位到,这个其实难度不大,用前面所讲的元素定位完全可以定位到的. 本篇以百度输入框输入关键字匹配后,打印出联想词汇. 一.定位输入框联想词 1.首 ...

  8. 一个简单的selenium实例(一)

    1.selenium RC+Eclipse下载安装 java环境 官网下载地址http://www.oracle.com/technetwork/java/javase/downloads/index ...

  9. Selenium2+python自动化34-获取百度输入联想词【转载】

    前言 最近有小伙伴问百度输入后,输入框下方的联想词如何定位到,这个其实难度不大,用前面所讲的元素定位完全可以定位到的. 本篇以百度输入框输入关键字匹配后,打印出联想词汇. 一.定位输入框联想词 1.首 ...

  10. Python+Selenium自动化-清空输入框、输入内容、点击按钮

    Python+Selenium自动化-清空输入框.输入内容.点击按钮   1.输入内容 send_keys('valve'):输入内容valve #定位输入框 input_box = browser. ...

随机推荐

  1. AOP实现参数的判空问题

    不想每次都去判断必传的参数是否为空,写代码太繁琐了,正好最近用了AOP实现权限控制,依葫芦画瓢,现在用它实现参数的判空,至于AOP的原理之类,自己百度了解一下吧 1. NullDisable注解 @D ...

  2. POJ 1659 Havel-Hakimi定理

    关于题意和Havel-Hakimi定理,可以看看http://blog.csdn.net/wangjian8006/article/details/7974845 讲得挺好的. 我就直接粘过来了 [ ...

  3. C - Tram

    Problem description Linear Kingdom has exactly one tram line. It has n stops, numbered from 1 to n i ...

  4. 用DIV遮罩解决checkbox勾选无效的问题

    在前端开发的过程中,遇到一种情况,需要勾选,为了用户的操作便捷就将click事件放到了DIV上.(其中使用了knockout.js) 代码大概如下: <div id="one" ...

  5. 【Oracle】DBMS_STATS.GATHER_TABLE_STATS

    月初一直在忙保监会报送的事情,苦逼的保险行业的ETL大家都懂的.今天闲来无事查看了一下前阵子的报送存储过程,发现系统隔一段时间就会调用一次DBMS_STATS.GATHER_TABLE_STATS,所 ...

  6. Python 之 %s字符串、%d整型、%f浮点型

    %s string="hello" #%s打印时结果是hello print "string=%s" % string # output: string=hel ...

  7. halcon 模板匹配 -- find_shape_model

    find_shape_model(Image : :  //搜索图像 ModelID, //模板句柄 AngleStart,  // 搜索时的起始角度 AngleExtent, //搜索时的角度范围, ...

  8. 【Hexo】deploy出错的解决方法

    .ERROR Deployer not found: git 执行npm install hexo-deployer-git --save .$ hexo d INFO Deploying: git ...

  9. Linux 之WinSCP连接FTP

    1.安装vsftpd 2.ftp命令 /sbin/service vsftpd start /sbin/service vsftpd restart /sbin/service vsftpd stop ...

  10. eas之日志文件夹

    F:\ThisIs_MyWork\kingdee\eas\server\profiles\server1\logs 服务端的日志文件夹    F:\ThisIs_MyWork\kingdeecusto ...