• <small id='zcoMB'></small><noframes id='zcoMB'>

      1. <legend id='zcoMB'><style id='zcoMB'><dir id='zcoMB'><q id='zcoMB'></q></dir></style></legend>
        <tfoot id='zcoMB'></tfoot>

        • <bdo id='zcoMB'></bdo><ul id='zcoMB'></ul>
        <i id='zcoMB'><tr id='zcoMB'><dt id='zcoMB'><q id='zcoMB'><span id='zcoMB'><b id='zcoMB'><form id='zcoMB'><ins id='zcoMB'></ins><ul id='zcoMB'></ul><sub id='zcoMB'></sub></form><legend id='zcoMB'></legend><bdo id='zcoMB'><pre id='zcoMB'><center id='zcoMB'></center></pre></bdo></b><th id='zcoMB'></th></span></q></dt></tr></i><div id='zcoMB'><tfoot id='zcoMB'></tfoot><dl id='zcoMB'><fieldset id='zcoMB'></fieldset></dl></div>

        如何在 C# 中使用 Firefox 启动特定 URL

        时间:2023-09-13
          <legend id='wObu9'><style id='wObu9'><dir id='wObu9'><q id='wObu9'></q></dir></style></legend>
            <tbody id='wObu9'></tbody>
            1. <small id='wObu9'></small><noframes id='wObu9'>

              <i id='wObu9'><tr id='wObu9'><dt id='wObu9'><q id='wObu9'><span id='wObu9'><b id='wObu9'><form id='wObu9'><ins id='wObu9'></ins><ul id='wObu9'></ul><sub id='wObu9'></sub></form><legend id='wObu9'></legend><bdo id='wObu9'><pre id='wObu9'><center id='wObu9'></center></pre></bdo></b><th id='wObu9'></th></span></q></dt></tr></i><div id='wObu9'><tfoot id='wObu9'></tfoot><dl id='wObu9'><fieldset id='wObu9'></fieldset></dl></div>
                <bdo id='wObu9'></bdo><ul id='wObu9'></ul>

                  <tfoot id='wObu9'></tfoot>
                1. 本文介绍了如何在 C# 中使用 Firefox 启动特定 URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  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:

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

                  Any suggestions? Thanks in advance.

                  解决方案

                  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.

                  这篇关于如何在 C# 中使用 Firefox 启动特定 URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:C# Selenium - 在不断增长的页面上查找元素 下一篇:如何通过Selenium和C#保存通过SendKeys()方法发送的字符序列

                  相关文章

                  <small id='NFbkQ'></small><noframes id='NFbkQ'>

                  <tfoot id='NFbkQ'></tfoot>

                      • <bdo id='NFbkQ'></bdo><ul id='NFbkQ'></ul>

                      <legend id='NFbkQ'><style id='NFbkQ'><dir id='NFbkQ'><q id='NFbkQ'></q></dir></style></legend>
                    1. <i id='NFbkQ'><tr id='NFbkQ'><dt id='NFbkQ'><q id='NFbkQ'><span id='NFbkQ'><b id='NFbkQ'><form id='NFbkQ'><ins id='NFbkQ'></ins><ul id='NFbkQ'></ul><sub id='NFbkQ'></sub></form><legend id='NFbkQ'></legend><bdo id='NFbkQ'><pre id='NFbkQ'><center id='NFbkQ'></center></pre></bdo></b><th id='NFbkQ'></th></span></q></dt></tr></i><div id='NFbkQ'><tfoot id='NFbkQ'></tfoot><dl id='NFbkQ'><fieldset id='NFbkQ'></fieldset></dl></div>