![](/img/trans.png)
[英]OpenQA.Selenium.WebDriverException : unknown error: Chrome failed to start: exited abnormally on CodeFresh
[英]OpenQA.Selenium.WebDriverException: unknown error: Chrome failed to start: exited abnormally while executing tests through Selenium start on linux
我創建了一個使用Selenium using.NetCore 的應用程序,以便在 Linux 上使用它,實際上這是我的代碼實現:
public class Program
{
public static async Task Main(string[] args)
{
//Settings for chrome
var chromeOpts = new ChromeOptions();
chromeOpts.AddArgument("headless");
chromeOpts.AddArgument("no-sandbox");
//Get assembly path where chrome driver is located
string codeBase = Assembly.GetExecutingAssembly().CodeBase;
UriBuilder uri = new UriBuilder(codeBase);
string path = Uri.UnescapeDataString(uri.Path);
path = Path.GetDirectoryName(path);
var driver = new ChromeDriver(path, chromeOpts, TimeSpan.FromSeconds(180));
}
}
如您所見,我正在使用 Chrome 作為驅動程序,我在這里下載了它,我還在程序集的文件夾中添加了驅動程序,這樣 ChromeDriver 就知道在哪里搜索它了。
在 linux 上,我使用chmod -R 777更改了文件夾權限,但是當我運行我的 Do.net 應用程序時,我得到了這個:
貌似Selenium無法啟動應用。 查看我得到的異常:
找不到 Chrome 二進制文件
不幸的是,我在 web 上沒有找到類似的東西,有人可以幫助我嗎?
提前致謝。
更新
我剛剛在我的 linux 機器上重新安裝了Chrome
,現在上面的錯誤消失了,但現在還有另一個問題,事實上我得到了這個錯誤:
OpenQA.Selenium.WebDriverException: unknown error: Chrome failed to start: exited abnormally (Driver info: chromedriver=2.9.248304,platform=Linux 4.4.0-130-generic x86_64)
at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
at OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities desiredCapabilities)
at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities)
at OpenQA.Selenium.Chrome.ChromeDriver..ctor(ChromeDriverService service, ChromeOptions options, TimeSpan commandTimeout)
at OpenQA.Selenium.Chrome.ChromeDriver..ctor(String chromeDriverDirectory, ChromeOptions options, TimeSpan commandTimeout)\ at ODS.Program.Main(String[] args)
這個錯誤信息...
OpenQA.Selenium.WebDriverException: unknown error: Chrome failed to start: exited abnormally
...暗示ChromeDriver無法啟動/生成新的WebBrowser,即Chrome 瀏覽器會話。
您的主要問題是您使用的二進制文件版本之間的不兼容,如下所示:
所以ChromeDriver版本 ( v2.33 ) 和最近的Chrome 瀏覽器版本 ( vVersion 68.0 ) 之間存在明顯的不匹配
@Test
。您可以在以下位置找到一些相關討論:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.