我使用的是Firefox,並且圖標在關閉之前會在任務欄中顯示半秒。然後,Firefox將與URL再次啓動Selenium:當創建新的IWebDriver時,瀏覽器啓動然後關閉,然後重新啓動一個新的會話
約:空白&的utm_content = firstrun
(即使主頁被設置爲谷歌)。
這可能是一個環境變量的問題?我沒有碰過這條路。
基本上,這是阻止我,因爲其他的語句會碰上NoSuchElementException異常......
這是我的代碼:
using System;
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.Support.UI;
namespace HomeAuto {
class Program
{
static void Main(string[] args)
{
IWebDriver driver = new FirefoxDriver();
Thread.Sleep(5000);
driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10));
driver.Navigate().GoToUrl("www.trademe.co.nz");
SelectElement categories = new SelectElement(driver.FindElement(By.Id("SearchType")));
categories.SelectByValue("202");
IWebElement searchBox = driver.FindElement(By.Id("searchString"));
searchBox.SendKeys("Some game");
searchBox.Submit();
driver.Close();
}
}
}
WaitForElement :) –
不幸的是,即使我評論構造下的所有內容出現問題。我已經嘗試了WaitForElement而不是睡眠者,但無濟於事。 – Lionfish