【问题标题】:chromedriver error - the error persists even with replacing the chromedriver executable from the said URLchromedriver 错误 - 即使从上述 URL 替换 chromedriver 可执行文件,错误仍然存​​在
【发布时间】:2020-07-16 13:53:12
【问题描述】:

使用 selenium 包后,它给了我 chromedriver.exe 不存在的错误。请让我知道是什么问题。我也按照对话框中的说明进行了操作,但问题仍然存在!下面是我的 c# 代码和 G1ANT Studio 的一些图片。

C#代码:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using G1ANT.Language;

using OpenQA.Selenium;

using OpenQA.Selenium.Chrome;

using OpenQA.Selenium.Firefox;

namespace G1ANT.Addon.YouTube
{
    [Command(Name = "youtube.open", Tooltip = "It opens youtube in a web browser")]
    class OpenCommand : Command
    {
        public OpenCommand(AbstractScripter scripter) : base(scripter)
        {

        }
        public class Arguments : CommandArguments
        {
            [Argument(Name = "browser", Required = true, Tooltip = "Type of browser; For Chrome, type: chrome; For Firefox, type: firefox")]
            public TextStructure Browser { get; set; } = new TextStructure();
        }
        public void Execute(Arguments argument)
        {
            if(argument.Browser.Value == "chrome")
            {
                IWebDriver driver = new ChromeDriver("C:/Users/Krishna/source/repos/G1ANT.Addon.YouTube/packages/Selenium.Chrome.WebDriver.83.0.0/driver/chromedriver");
                driver.Navigate().GoToUrl(@"https://www.youtube.com/");
            }
            else if(argument.Browser.Value == "firefox")
            {
                IWebDriver driver = new FirefoxDriver("C:/Users/Krishna/source/repos/G1ANT.Addon.YouTube/packages/Selenium.Firefox.WebDriver.0.26.0/driver/geckodriver");
                driver.Navigate().GoToUrl(@"https://www.youtube.com/");
            }
            else
            {
                RobotMessageBox.Show("Wrong input" + argument.Browser.Value + "\n For Chrome, type: chrome; For Firefox, type: firefox");
            }
        }
    }
}

G1ANT Studio 中的错误:

我在 G1ANT Studio 中运行“youtube.open browser chrome”命令后,它说 chromedriver.exe 不存在

【问题讨论】:

标签: c# selenium-webdriver c#-4.0 c#-3.0 g1ant


【解决方案1】:

此链接上的答案是其中之一,有助于解决此错误!

https://stackoverflow.com/a/51608925/13725510

其次,我修改了路径,请参考问题中的代码和以下代码(错误解决),其中提到路径的那一行:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using G1ANT.Language;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Firefox;

namespace G1ANT.Addon.YouTube
{
    [Command(Name = "youtube.open", Tooltip = "It opens youtube in a web browser")]
    class OpenCommand : Command
    {
        public OpenCommand(AbstractScripter scripter) : base(scripter)
        {

        }
        public class Arguments : CommandArguments
        {
            [Argument(Name = "browser", Required = true, Tooltip = "Type of browser; For Chrome, type: chrome; For Firefox, type: firefox")]
            public TextStructure Browser { get; set; } = new TextStructure();
        }
        public void Execute(Arguments argument)
        {
            if(argument.Browser.Value == "chrome")
            {
                IWebDriver driver = new ChromeDriver("C:/Users/Krishna/source/repos/G1ANT.Addon.YouTube/packages/Selenium.Chrome.WebDriver.83.0.0/driver");
                driver.Navigate().GoToUrl(@"https://www.youtube.com/");
            }
            else if(argument.Browser.Value == "firefox")
            {
                IWebDriver driver = new FirefoxDriver("C:/Users/Krishna/source/repos/G1ANT.Addon.YouTube/packages/Selenium.Firefox.WebDriver.0.26.0/driver");
                driver.Navigate().GoToUrl(@"https://www.youtube.com/");
            }
            else
            {
                RobotMessageBox.Show("Wrong input: " + argument.Browser.Value + "\n For Chrome, type: chrome; For Firefox, type: firefox");
            }
        }
    }
}

【讨论】:

    猜你喜欢
    • 2021-06-15
    • 2021-08-19
    • 2018-12-14
    • 2020-11-04
    • 2018-08-18
    • 2019-08-01
    • 2019-11-11
    • 2015-07-03
    相关资源
    最近更新 更多