In C# Selen gefunden, ich bin FindElement mit einem Element zu finden, die nicht in der Seite ist, sondern NoSuchElementException
das Erhalten ich WebDriverException
C# Selen: Erste WebdriverException, wenn das Element nicht
Die Ausnahme ist:
at OpenQA.Selenium.Remote.HttpCommandExecutor.CreateResponse(WebRequest request)
at OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(Command commandToExecute)
at OpenQA.Selenium.Firefox.FirefoxDriverCommandExecutor.Execute(Command commandToExecute)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
at OpenQA.Selenium.Remote.RemoteWebDriver.FindElement(String mechanism, String value)
at org.myorg.DriverUtils.FindElement(By by, Boolean raiseException, Boolean setTestFail, Int32 currentAttempt)
die WebDriver:
var downloadDir = "path to downoads";
var fxprofile = new FirefoxProfile();
fxprofile.SetPreference("browser.download.folderList", 2);
fxprofile.SetPreference("browser.download.dir", downloadDir);
fxprofile.SetPreference("browser.download.defaultFolder", downloadDir);
fxprofile.SetPreference("browser.download.useDownloadDir", true);
fxprofile.SetPreference("pdfjs.disabled", true);
var profileM = new FirefoxProfileManager();
var profile = profileM.GetProfile("fxprofile");
var options = new FirefoxOptions();
var firefoxBinary = "path to firefox exe";
Driver = new FirefoxDriver(firefoxBinary, fxprofile);
try{
Driver.FindElement(By.Id("non exeistant element"));
}
catch (NoSuchElementException e)
{
// not hit
}
catch (WebDriverException e)
{
//Hit here
// Another thing i noticed is it takes almost a minute to actually throw this exception from the FindElement
}
Dies sieht nicht wie eine Ausnahme aus, sondern die Stack-Ablaufverfolgung der Ausnahme, Sie müssen die Ausnahme auch posten. Wird dein Firefox gestartet? –
ja Firefox startet., Als ich durch den Code (F10) navigiert, traf es die WebdriverException –