剛開始嘗試Selenium
並且無法使腳本與ChromeDriver
一起運行。 所有我試圖讓它做的是打開瀏覽器,並在腳本中的URL。Selenium Chromedriver不會在啓動時輸入網址
問題是,瀏覽器打開,但沒有任何反應,瀏覽器只是坐在那裏無所事事。
最初我只是有以下行,但ChromeDriver
不斷崩潰,我添加了在主腳本中看到的行,並且崩潰已停止,但仍然無效。
第一個腳本:
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
namespace WebDriverDemo
{
class Program
{
static void Main(string[] args)
{
IWebDriver driver = new ChromeDriver(@"C:\Libraries\");
driver.Url = "https://www.google.com";
}
}
}
在沒有墜毀,但沒有結果最終想這兩種。
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
namespace WebDriverDemo
{
class Program
{
static void Main(string[] args)
{
var options = new ChromeOptions();
options.AddArguments("test-type");
options.ToCapabilities();
ChromeDriverService service = ChromeDriverService.CreateDefaultService(@"C:\Libraries\");
IWebDriver driver = new ChromeDriver(service, options);
// Tried both of the below
driver.Navigate().GoToUrl("https://www.google.com");
driver.Url = "https://www.google.com";
}
}
}
下載它通常意味着驅動程序版本與瀏覽器版本不匹配。 – JeffC