如何通过FirefoxProfile启动Mozilla浏览会话? [英] How to initiate a Mozilla Browsing session through FirefoxProfile?

查看:107
本文介绍了如何通过FirefoxProfile启动Mozilla浏览会话?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Firefox分析.但是它在代码的下面一行抛出了错误.请查看所附的快照

I am trying to use Firefox Profiling. But it is throwing an error at below line in the code. Please see attached snapshot

请,有人可以帮忙吗?

代码:-

WebDriver driver = new FirefoxDriver(prof);

错误:->

构造函数FirefoxDriver(FirefoxProfile)未定义

The constructor FirefoxDriver(FirefoxProfile) is undefined

我正在使用的以下版本:-

Below versions I am using:-

  • 硒-> 3.12.0
  • Firefox设置50.0

代码:

 import java.util.concurrent.TimeUnit;
 import org.openqa.selenium.WebDriver;
 import org.openqa.selenium.firefox.FirefoxDriver;
 import org.openqa.selenium.firefox.FirefoxProfile;
 import org.openqa.selenium.firefox.internal.ProfilesIni;
 public class Gmail {

    public static void main(String[] args) {
       System.setProperty("webdriver.gecko.driver", "D:\\Drivers\\geckodriver.exe");

       ProfilesIni allProf = new ProfilesIni();// all profiles
       FirefoxProfile prof = allProf.getProfile("Abhi_Selenium");

       WebDriver driver = new FirefoxDriver(prof);
       driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
       driver.get("http://gmail.com");

推荐答案

没有这样的构造函数来获取配置文件并创建驱动程序.那就是异常告诉你的.您可以在此处查看javadoc:

There isn't such constructor that gets the profile and creates the driver. That's what the exception is telling you. You can see the javadoc here:

https://seleniumhq .github.io/selenium/docs/api/java/org/openqa/selenium/firefox/FirefoxDriver.html

您可以尝试类似的操作:

You can try something like that:

FirefoxOptions options = new FirefoxOptions();
options.setProfile(yourProfile);
FirefoxDriver driver = new FirefoxDriver(options);

这篇关于如何通过FirefoxProfile启动Mozilla浏览会话?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆