无法使用 Selenium Chrome Driver c# 启动 window
Cant Launch a window with Selenium Chrome Driver c#
环境:
VS2019,C#
NuGet 包:Selenium 委员会的 Selenium v3.141.0。
Chrome 来自 Selenium 网站的驱动程序 - v92.0
IWebDriver Driver = new ChromeDriver("FolderPath"); //这里超时错误。
Driver.url = "www.google.com"
没有其他代码,我无法通过声明 Chrome 驱动程序。我收到本地主机超时错误。
我试过了:
设置不同的端口。
在参数中添加“无沙盒”。
我会尝试使用 ChromeDriver NuGet 包而不是指向本地文件位置
https://www.nuget.org/packages/Selenium.WebDriver.ChromeDriver/
这里有一个简单的例子供大家参考
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Support.UI;
namespace ExampleDemo
{
[TestFixture]
public class Chrome_test
{
private IWebDriver driver;
[Test(Description="Go To Google")]
public void GoToGoogle() {
homeURL = https://www.google.com/;
driver.Navigate().GoToUrl(homeURL);
}
[TearDown]
public void TearDownTest()
{
driver.Close();
}
[SetUp]
public void SetupTest()
{
driver = new ChromeDriver();
}
}
}
我需要添加一个chrome选项:
ChromeOptions options = new ChromeOptions()
options.add("--remote-debugging-port=9222 ") // change port if necessary
环境: VS2019,C# NuGet 包:Selenium 委员会的 Selenium v3.141.0。 Chrome 来自 Selenium 网站的驱动程序 - v92.0
IWebDriver Driver = new ChromeDriver("FolderPath"); //这里超时错误。 Driver.url = "www.google.com"
没有其他代码,我无法通过声明 Chrome 驱动程序。我收到本地主机超时错误。 我试过了: 设置不同的端口。 在参数中添加“无沙盒”。
我会尝试使用 ChromeDriver NuGet 包而不是指向本地文件位置 https://www.nuget.org/packages/Selenium.WebDriver.ChromeDriver/
这里有一个简单的例子供大家参考
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Support.UI;
namespace ExampleDemo
{
[TestFixture]
public class Chrome_test
{
private IWebDriver driver;
[Test(Description="Go To Google")]
public void GoToGoogle() {
homeURL = https://www.google.com/;
driver.Navigate().GoToUrl(homeURL);
}
[TearDown]
public void TearDownTest()
{
driver.Close();
}
[SetUp]
public void SetupTest()
{
driver = new ChromeDriver();
}
}
}
我需要添加一个chrome选项:
ChromeOptions options = new ChromeOptions()
options.add("--remote-debugging-port=9222 ") // change port if necessary