【问题标题】:Load site in firefox when use selenium web driver使用 selenium web 驱动程序时在 Firefox 中加载站点
【发布时间】:2014-12-09 12:04:15
【问题描述】:

我的默认浏览器是 firefox。但是当我尝试使用 selenium 网络驱动程序加载文件时,它会自动通过谷歌浏览器加载。如何将其更改为 Firefox? Eclipse 首选项也已设置为默认浏览器。

    package com.selenium.example;

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

    public class ExampleSelenium {

public static void main(String[] args) {
    FirefoxDriver driver = new FirefoxDriver();
    driver.get("http://localhost:3030/fuseki.html");
}}

【问题讨论】:

  • 如果你写这个 FirefoxDriver driver = new FirefoxDriver();那么它必须在 Firefox 中打开。
  • @HelpingHands 那没有发生。这就是我的问题。它总是通过谷歌浏览器加载。我在谷歌浏览器中更改了代理设置。因此不支持本地主机。所以我想通过firefox加载localhost。
  • 如果你使用其他网址怎么办?而不是本地主机?喜欢 google.com 吗?是在 Firefox 中打开的吗?
  • @HelpingHands 是的。火狐。
  • 然后我认为它的本地主机问题..尝试使用方法 driver.Navigate().GoToURL()

标签: java eclipse selenium selenium-webdriver


【解决方案1】:

请使用以下方法获取网址:

 driver.getUrl("Your host link"); 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-07-19
    • 2017-03-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多