【问题标题】:How to change Firefox WebDriver Port如何更改 Firefox WebDriver 端口
【发布时间】:2014-08-26 08:28:45
【问题描述】:

我只是好奇如何在 IE 和 Chrome 驱动程序等不同端口上运行 firefox 驱动程序。这个驱动程序有类似的选项

ChromeDriverService service=new ChromeDriverService.Builder().usingPort(7000).
                                            usingDriverExecutable(new File("")).build();

虽然 Firefox 驱动程序有这样的选项

System.setProperty("webdriver.firefox.port","7046");

DesiredCapabilities cap=new DesiredCapabilities();
cap.setCapability("webdriver_firefox_port",7046);

但它无法在此端口上运行 firefox 驱动程序我使用的是 2.41 Selenium Webdriver 和 firefox 31

谁能解释我为什么以及如何在指定端口运行 Firefox 驱动程序。

【问题讨论】:

    标签: java firefox selenium-webdriver


    【解决方案1】:

    嗯,不确定,但这应该可以工作

    ProfilesIni allProfiles = new ProfilesIni();
    FirefoxProfile profile = allProfiles.getProfile("WebDriver");
    profile.setPreference(FirefoxProfile.PORT_PREFERENCE, 7046)
    WebDriver driver = new FirefoxDriver(profile);
    

    【讨论】:

    • 感谢您的评论.......我之前这样做过,但它不起作用,但我使用默认配置文件“用户”......默认配置文件。
    • 我也在创建新配置文件后尝试了这个,但我得到了相同的结果它在默认端口 7055 而不是 7046 上运行
    • 非常有趣,但如果只使用没有 getProfile 的 FirefoxProfile?!,例如FirefoxProfile profile = new FirefoxProfile(); profile.setPreference("webdriver.firefox.port", 7046); WebDriver driver = new FirefoxDriver(profile); 。我从来没有遇到过这样的问题=),并且非常有趣如何解决它。
    • 我也这样做,但它无法访问定义的端口.....你能帮我摆脱这个吗?
    • 我会尽力提供帮助的。 1. 为什么你需要改变你的fireFox端口?这可能不是必需的吗? 2. 主要测试过程是什么(您是使用 selenium 网格,还是仅从代码运行测试)。与测试相关的任何其他描述/它的目的都会有所帮助
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-07-26
    • 2011-07-19
    • 2014-09-14
    • 2012-02-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多