【发布时间】:2017-12-10 06:47:52
【问题描述】:
我使用 selenium 编写了一个 C# 程序。在 Windows 上使用它时效果很好,但在 Rapsberry Pi 上却不行。 [它可以在没有硒部分的情况下工作]。
代码如下:
var options = new FirefoxOptions();
options.BrowserExecutableLocation = @"C:\Program Files (x86)\Mozilla Firefox\firefox.exe";
//IWebDriver driver = new FirefoxDriver(options); // WINDOWS VERSION
IWebDriver driver = new FirefoxDriver(); // LINUX VERSION
string xpath = "html/body/div[1]/div/main/div/section/section[2]/div/div[2]/div[1]/div/div/textarea";
string xpathButton = "html/body/div[1]/div/main/div/section/section[2]/div/div[2]/div[1]/div/button";
driver.Url = myurl;
driver.FindElement(By.XPath(xpathButton)).Click();
List<IWebElement> webElems = driver.FindElements(By.XPath(xpath)).ToList();
string comparestring = "";
int comparecounter = 0;
foreach (IWebElement element in webElems)
{
comparestring = element.Text;
}
我在树莓派上不断收到以下错误:
连接被拒绝
和: OpenQA.Selenium.WebDriverException:无法找到一组匹配的功能 在 OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError (OpenQA.Selenium.Remote.Response errorResponse) [0x00000] in :0 在 OpenQA.Selenium.Remote.RemoteWebDriver.Execute(System.String driverCommandToExecute,System.Collections.Generic.Dictionary`2 参数)[0x00000] 中:0 在 OpenQA.Selenium.Remote.RemoteWebDriver.StartSession (ICapabilities desiredCapabilities) [0x00000] in :0 在 OpenQA.Selenium.Remote.RemoteWebDriver..ctor (ICommandExecutor commandExecutor, ICapabilities desiredCapabilities) [0x00000] in :0 在 OpenQA.Selenium.Firefox.FirefoxDriver..ctor (OpenQA.Selenium.Firefox.FirefoxDriverService 服务,OpenQA.Selenium.Firefox.FirefoxOptions 选项,TimeSpan 命令超时)[0x00000] 中:0 在 OpenQA.Selenium.Firefox.FirefoxDriver..ctor (OpenQA.Selenium.Firefox.FirefoxOptions 选项)[0x00000] 中:0 在 OpenQA.Selenium.Firefox.FirefoxDriver..ctor () [0x00000] 中:0 在 Dialga.MyBot+c__async8.MoveNext () [0x00000] in :0
【问题讨论】:
-
猜测你在 Pi 上的 Firefox 可执行文件的路径是错误的
-
我对此表示怀疑,但我现在正在尝试以下路径:/usr/share/applications/firefox-esr.desktop
-
我仍然遇到同样的错误,所以这并没有解决问题。 [又走错路了?]
标签: c# selenium-webdriver raspberry-pi connection connection-refused