使用 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 不存在