【cl】selenium实例2:打开百度,输入hello world
/*创建的类为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的更多相关文章
- python selenium启动浏览器打开百度搜索
python selenium打开百度搜索 #!usr/bin/python from selenium import webdriver import time browser = webdrive ...
- 【cl】selenium实例一:打开百度,获取第四个标题
/*创建类的时候是TestNG Class*/ package Selenium_lassen; import static org.junit.Assert.*; import java.util. ...
- selenium基础-打开百度进行搜索
1. 安装Python 2. 安装selenium 3. 下载谷歌驱动ChromeDriver,放到Python的Scripts目录下 4. 编写代码,如下 # coding: utf-8 from ...
- selenium实例:unittest框架+PO开发模式
这是<selenium2+python学习总结>的升级版. 1. 项目结构 2. 项目代码 1) globalparameter.py # ...
- Python+Selenium基础篇-打开和关闭火狐浏览器
本节介绍如何初始化一个webdriver实例对象driver,然后打开和关闭firefox浏览器.要用selenium打开fiefox浏览器.首先需要去下载一个driver插件geckodriver. ...
- Selenium2学习-009-WebUI自动化实战实例-007-Selenium 8种元素定位实战实例源代码(百度首页搜索录入框及登录链接)
此 文主要讲述用 Java 编写 Selenium 自动化测试脚本编写过程中,通过 ID.name.xpath.cssSelector.linkText.className.partialLinkTe ...
- Selenium2+python自动化34-获取百度输入联想词
前言 最近有小伙伴问百度输入后,输入框下方的联想词如何定位到,这个其实难度不大,用前面所讲的元素定位完全可以定位到的. 本篇以百度输入框输入关键字匹配后,打印出联想词汇. 一.定位输入框联想词 1.首 ...
- 一个简单的selenium实例(一)
1.selenium RC+Eclipse下载安装 java环境 官网下载地址http://www.oracle.com/technetwork/java/javase/downloads/index ...
- Selenium2+python自动化34-获取百度输入联想词【转载】
前言 最近有小伙伴问百度输入后,输入框下方的联想词如何定位到,这个其实难度不大,用前面所讲的元素定位完全可以定位到的. 本篇以百度输入框输入关键字匹配后,打印出联想词汇. 一.定位输入框联想词 1.首 ...
- Python+Selenium自动化-清空输入框、输入内容、点击按钮
Python+Selenium自动化-清空输入框.输入内容.点击按钮 1.输入内容 send_keys('valve'):输入内容valve #定位输入框 input_box = browser. ...
随机推荐
- docker(一):docker是什么?
认识容器:docker入门篇 docker是什么? Docker 是一个开源的应用容器引擎,让开发者可以打包他们的应用以及依赖包到一个可移植的容器中,然后发布到任何流行的Linux机器上,也可以实现虚 ...
- C - Domino piling
Problem description You are given a rectangular board of M × N squares. Also you are given an unlimi ...
- Spring Boot (5) Spring Boot配置详解
application.properties application.properties是spring boot默认的配置文件,spring boot默认会在以下两个路径搜索并加载这个文件 src\ ...
- unicode、UTF-8、UTF-16的历史
1:中国人民通过对 ASCII 编码的中文扩充改造,产生了 GB2312 编码,可以表示6000多个常用汉字. 2:汉字实在是太多了,包括繁体和各种字符,于是产生了 GBK 编码,它包括了 GB231 ...
- macOS下登录store或者xcode等应用时提示【this action could not be completed】
sudo mkdir -p /Users/Shared sudo chown root:wheel /Users/Shared sudo chmod -R 1777 /Users/Shared === ...
- openMSP430之Custom linker script
The use of the -mmcu switch is of course NOT mandatory. It is simply a convenient way to use the pre ...
- dubbo之启动时检查
启动时检查 Dubbo缺省会在启动时检查依赖的服务是否可用,不可用时会抛出异常,阻止Spring初始化完成,以便上线时,能及早发现问题,默认 check="true".所以可以通过 ...
- 【sqli-labs】 less16 POST - Blind- Boolian/Time Based - Double quotes (基于bool型/时间延迟的双引号POST型盲注)
' or 1=1# -->失败 1" or 1=1# -->失败 1') or 1=1# -->失败 1") or 1=1# -->成功 判断为双引号变形注 ...
- Arduino DS18B20温度检测
一.实物图 注:电阻选取4.7k欧 二.事例代码 注:先下载Onewire库到arduino libraries目录下,然后就有例子 #include <OneWire.h> // One ...
- (转)基于Metronic的Bootstrap开发框架经验总结(7)--数据的导入、导出及附件的查看处理
http://www.cnblogs.com/wuhuacong/p/4777720.html 在很多系统模块里面,我们可能都需要进行一定的数据交换处理,也就是数据的导入或者导出操作,这样的批量处理能 ...