描述

本文主要是针对Chrome 62 , firefox57 ,和IE11 三个版本的操作。相关的driver 。可点击以下链接。所有的driver 建议放在浏览器的目录下,本文中所有的driver都放置在对应的浏览器根目录下。

https://files.cnblogs.com/files/linxinmeng/IE11_win10_3.5.zip

https://files.cnblogs.com/files/linxinmeng/Firefox57_win10_java1.8.zip

https://files.cnblogs.com/files/linxinmeng/chromedriver_X64_Chrome62.zip

注意事项

IE浏览器需要对安全进行设置 。以及【设置】中的缩放必须是100%。

 package 票务系统前台;

 import java.util.concurrent.TimeUnit;

 import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxOptions;
import org.openqa.selenium.firefox.FirefoxProfile;
import org.openqa.selenium.firefox.internal.ProfilesIni;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.remote.DesiredCapabilities; public class 浏览器操作 {
static WebDriver driver; public static void main(String[] args) {
// IE_open(driver);
// firefox_Open1(driver);
chrome_Open(driver);
} public static WebDriver chrome_Open(WebDriver driver) {
System.setProperty("webdriver.chrome.driver", "D:\\driver\\chromedriver_X64\\chromedriver_X64.exe");
ChromeOptions Options = new ChromeOptions();
Options.addArguments("user-data-dir=C:\\Users\\linxinmeng\\AppData\\Local\\Google\\Chrome\\User Data");
driver = new ChromeDriver(Options);
driver.manage().timeouts().implicitlyWait(8, TimeUnit.SECONDS); driver.get("http://www.baidu.com");
return driver;
} public static WebDriver IE_open(WebDriver driver) {
System.setProperty("webdriver.ie.driver", "C:\\Program Files (x86)\\Internet Explorer\\IEDriverServer.exe");
driver = new InternetExplorerDriver();
driver.get("http://www.baidu.com");
return driver; } public static WebDriver firefox_Open1(WebDriver driver) { System.setProperty("webdriver.firefox.bin", "D:\\软件应用宝\\Mozilla Firefox\\firefox.exe");
System.setProperty("webdriver.gecko.driver", "D:\\软件应用宝\\Mozilla Firefox\\geckodriver.exe");
FirefoxOptions ffo = new FirefoxOptions();
driver = new FirefoxDriver(ffo);
driver.get("https://www.baidu.com");
return driver;
} }

selenium webdriver操作各浏览器的更多相关文章

  1. Selenium webdriver 操作chrome 浏览器

    Step1: 下载chromedriver. 下载路径: http://chromedriver.storage.googleapis.com/index.html 选择一个合适的下载即可.我下载的是 ...

  2. Selenium webdriver 操作IE浏览器

    V1.0版本:直接新建WebDriver使用 import org.openqa.selenium.WebDriver; import org.openqa.selenium.ie.InternetE ...

  3. Selenium WebDriver使用IE浏览器

    摘:http://www.cnblogs.com/dream0577/archive/2012/10/07/2714579.html /**       用IE驱动,1.先到官网下载IEDriverS ...

  4. selenium webdriver启动Chrome浏览器后无法输入网址的解决办法

    通过selenium webdriver启动Chrome浏览器,脚本如下: from selenium import webdriver browser = webdriver.Chrome() br ...

  5. selenium webdriver启动IE浏览器失败的解决办法

    通过selenium webdriver启动IE浏览器失败,报错:selenium.common.exceptions.WebDriverException: Message: Unexpected ...

  6. selenium webdriver 启动三大浏览器Firefox,Chrome,IE

    selenium webdriver 启动三大浏览器Firefox,Chrome,IE 1.安装selenium 在联网的情况下,在Windows命令行(cmd)输入pip install selen ...

  7. Selenium Webdriver——操作隐藏的元素(三)switchTo().frame()

    在web 应用中经常会遇到frame 嵌套页面的应用,页WebDriver 每次只能在一个页面上识别元素,对于frame 嵌套内的页面上的元素,直接定位是定位是定位不到的.这个时候就需要通过switc ...

  8. Selenium Webdriver——操作隐藏的元素(二)display属性

    有时候我们会碰到一些元素不可见,这个时候selenium就无法对这些元素进行操作了.例如,下面的情况: 页面主要通过“display:none”来控制整个下拉框不可见.这个时候如果直接操作这个下拉框, ...

  9. Selenium Webdriver——操作隐藏的元素

    有时候我们会碰到一些元素不可见,这个时候selenium就无法对这些元素进行操作了.例如,下面的情况: 页面主要通过“display:none”来控制整个下拉框不可见.这个时候如果直接操作这个下拉框, ...

随机推荐

  1. 【NOIP2017】列队(Splay)

    [NOIP2017]列队(Splay) 题面 洛谷 题解 其实好简单啊... 对于每一行维护一棵\(Splay\) 对于最后一列维护一棵\(Splay\) \(Splay\)上一个节点表示一段区间 每 ...

  2. 洛谷 [POI2007]BIU-Offices 解题报告

    [POI2007]BIU-Offices 题意 给定\(n(\le 100000)\)个点\(m(\le 2000000)\)条边的无向图\(G\),求这个图\(G\)补图的连通块个数. 一开始想了半 ...

  3. Hive(五)hive的高级应用

    一.视图 视图:享用基本表的数据,不会生成另外一份数据创建视图:create view view_name as select * from carss;create view carss_view ...

  4. bzoj3143: [Hnoi2013]游走(贪心+高斯消元)

    考虑让总期望最小,那么就是期望经过次数越多的边贪心地给它越小的编号. 怎么求每条边的期望经过次数呢?边不大好算,我们考虑计算每个点的期望经过次数f[x],那么一条边的期望经过次数就是f[x]/d[x] ...

  5. 音视频处理之FFmpeg程序的介绍与使用20180302

    一.FFMPEG程序介绍与使用 主要介绍一下ffmpeg工程包含的三个exe的使用方法. 1. FFMPEG程序介绍 1.1.下载 ffmpeg的官方网站是:http://ffmpeg.org/ 下载 ...

  6. codeforces gym 100952 A B C D E F G H I J

    gym 100952 A #include <iostream> #include<cstdio> #include<cmath> #include<cstr ...

  7. 用for语句从数组中剔除数据,注意,count,要放到for语句之外才行

    date_default_timezone_set('Asia/Shanghai'); $arr = array( ,), ,), ,), ,) ); print_r($arr); ;$i<co ...

  8. [DeeplearningAI笔记]序列模型2.7负采样Negative sampling

    5.2自然语言处理 觉得有用的话,欢迎一起讨论相互学习~Follow Me 2.7 负采样 Negative sampling Mikolov T, Sutskever I, Chen K, et a ...

  9. Win10环境下配置VScode的C++编译环境

    写前感想:前前后后,折腾好几次,最后还是在学长安利下,开始入坑vscode了.原因一个是小巧,还有就是vs新建工程码题的方式太消耗内存了,基本每个项目就是以MB为单位计算的,然后希望用这篇文章记录自己 ...

  10. 分块+deque维护 Codeforces Round #260 (Div. 1) D. Serega and Fun

    D. Serega and Fun time limit per test 4 seconds memory limit per test 256 megabytes input standard i ...