0

I'have written a C# pogram using selenium. It works perfelcty fine when using it on windows, but not on the Rapsberry Pi. [It works without the selenium part].

Here is the code:

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;
}

I keep getting the following error on the raspberry pi:

Connection refused

and: OpenQA.Selenium.WebDriverException: Unable to find a matching set of capabilities at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError (OpenQA.Selenium.Remote.Response errorResponse) [0x00000] in :0 at OpenQA.Selenium.Remote.RemoteWebDriver.Execute (System.String driverCommandToExecute, System.Collections.Generic.Dictionary`2 parameters) [0x00000] in :0 at OpenQA.Selenium.Remote.RemoteWebDriver.StartSession (ICapabilities desiredCapabilities) [0x00000] in :0 at OpenQA.Selenium.Remote.RemoteWebDriver..ctor (ICommandExecutor commandExecutor, ICapabilities desiredCapabilities) [0x00000] in :0 at OpenQA.Selenium.Firefox.FirefoxDriver..ctor (OpenQA.Selenium.Firefox.FirefoxDriverService service, OpenQA.Selenium.Firefox.FirefoxOptions options, TimeSpan commandTimeout) [0x00000] in :0 at OpenQA.Selenium.Firefox.FirefoxDriver..ctor (OpenQA.Selenium.Firefox.FirefoxOptions options) [0x00000] in :0 at OpenQA.Selenium.Firefox.FirefoxDriver..ctor () [0x00000] in :0 at Dialga.MyBot+c__async8.MoveNext () [0x00000] in :0

Gami
  • 1
  • 1

1 Answers1

0

So I got it working. The reason it did not work properly was a mismatch between Firefox and the geckodriver-versions. I solved it by downloading Firefox 52.2-ESR and using geckdrover 1.7. [Selenium 3.4].

Sadly Firefox is way to slow on the raspberry Pi so I switched it all up for the PhantomJS webdriver.

Gami
  • 1
  • 1