Selenium之firefox浏览器的启动

1、编写如下代码

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

/**
 * Created by Administrator on 2018/3/29 0029.
 */
public class FirefoxTest {
    public static void main(String[] args){
        WebDriver driver;
        //启动找不到firefox才需要设置
        System.setProperty("webdriver.firefox.bin","D:\\ztsoft\\Firefox\\firefox.exe");
        //实例化一个对象firefox
        driver =  new FirefoxDriver();
        String testUrl = "http://www.baidu.com";
        driver.get(testUrl);
        driver.quit();
    }

2、执行代码,弹出firefox,地址栏输入代码设置的地址。

原文地址:https://www.cnblogs.com/biyuting/p/8673215.html

时间: 2024-08-28 05:44:59

Selenium之firefox浏览器的启动的相关文章

Selenium驱动Firefox浏览器

用Maven构建Selenium依赖 <dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-java</artifactId> <version>3.8.1</version></dependency> import org.openqa.selenium.By;import org.openqa.seleniu

解决Selenium与firefox浏览器版本不兼容问题

因为在用java打开firefox浏览器的时候报错 org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms 在网上查阅了说是兼容问题 然后就开始找selenium版本与对应firefox版本匹配的记录 各firefox版本下载地址 http://ftp.mozilla.org/pub/firefox/releases/ 各s

[乐意黎原创] 使用Selenium webdriver+Firefox浏览器来登录新浪微博

有个需求测试,需要用webdriver 登录到新浪微博,由于个人比较善长 Webdriver,于是采取了Webdriver+FireFox来实现. 配置环境 a. 必须首先在Eclipse里加载 selenium webdriver 包[[此处我导入的是 selenium-server-standalone-2.45.0.jar] b. 以及安装了 firefox 浏览器. 此篇文章中我用了本人的新浪微博地址来做测试,大家 可以更换为自己的新浪微博帐号和密码. 文中为部分主要的Java 代码.

Selenium之Chrome浏览器的启动

1.下载Chromedriver.exe文件放至需要的目录中: 2.编写代码 import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; /** * Created by Administrator on 2018/3/29 0029. */ public class ChromeTest { public static void main(String[] args){ WebDri

Selenium之Chrome浏览器的启动问题及解决

System.setProperty("webdriver.chrome.driver","chromedriver.exe路径"); 配置好Chrome的驱动之后,执行,报以下错误: 三月 29, 2018 10:47:27 下午 org.openqa.selenium.os.UnixProcess checkForError 严重: org.apache.commons.exec.ExecuteException: Execution failed (Exit

Selenium之IE浏览器的启动问题及解决

前面有篇文章说到启动IE浏览器时,会出现以下错误提示: 浏览器启动之后,页面不会自动输入代码设置的地址,如下图展示 查看报错语句,发现原来是浏览器比例调的不正确,修改浏览器比例为100%即可解决该问题 原文地址:https://www.cnblogs.com/biyuting/p/8678679.html

Selenium webdriver firefox 带配置启动

FirefoxProfile firefoxProfile=new FirefoxProfile(new File("/Users/zhangminjie/Library/Application Support/Firefox/Profiles/y1qo9afq.default")); driver = new FirefoxDriver(firefoxProfile);

python中使用selenium错误-Firefox浏览器

今天下午学习了一下编写自动化脚本,遇到的问题,记录一下. 解决方法:下载geckodriver.exe,将下载好的geckodriver.exe放入到D:\MyConfiguration\wtt42800\AppData\Local\Programs\Python\Python36-32(python的安装目录) 参考链接:http://jingyan.baidu.com/article/c910274b87b84acd361d2da3.html https://github.com/mozil

启动带有用户配置信息的FireFox浏览器

今天自己写了一个简单的登录HTML网页,在用Selenium+FireFox调用时发现浏览器出现了乱码,之后百度发现是因为浏览器设置的编码格式不是"UTF-8",之后修改浏览器编码为"UTF-8"之后,再次运行程序发现还是乱码,但是直接打开浏览器浏览网页,字符编码已经正常了,之后查询了资料才知道是由于WebDriver启动FireFox浏览器时会启动全新的FireFox浏览器窗口,导致当前机器用户的浏览器配置信息均在测试中无法被使用,要解决这一问题,就需要为使用指定