Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'm trying to launch a specific URL using Firefox. But I'm only able to open Firefox browser and not able to launch that URL.

class BrowserHelper
{
    IWebDriver driver;
    string path = Path.Combine(Environment.CurrentDirectory, @"gecko");
    public void Navigate(string url)
    {
        path = path.Replace(@"", @"");
        var driverService = FirefoxDriverService.CreateDefaultService(path);
        driverService.HideCommandPromptWindow = true;
        if (driver == null)
        {
            driver = new FirefoxDriver(driverService);
        }
            driver.Url = url;
            driver.Navigate().GoToUrl(driver.Url);
            driver.Manage().Window.Maximize();
    }
}
class Realtest
{
    BrowserHelper BH = new BrowserHelper();
    public void test()
    {
        string search ="apple";
        BH.Navigate("https://www.google.com/search?q=" + search);
    }
}

And I can only get this page: enter image description here

Here's the final URL I want to launch: https://www.google.com.sg/search?q=apple

Any suggestions? Thanks in advance.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.2k views
Welcome To Ask or Share your Answers For Others

1 Answer

I have tried the below code (in Java), and it's working fine by launching the browser and loading the URL also.

System.setProperty("webdriver.gecko.driver","Drivers/geckodriver.exe");
WebDriver driver = new FirefoxDriver();
driver.get("https://www.google.com.sg/search?q=apple");

So I feel the problem is with geckodriver version and FireFox browser installed in your local machine. I would suggest you update FireFox and geckodriver to the latest version.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...