這是我的問題: 我只是試圖運行基本測試,只是爲了嘗試這一點,並且一直運行例外:「OpenQA.Selenium.WebDriverException:向遠程WebDriver服務器發送的URL請求URL (url here)超時60秒後」。OpenQA.Selenium.WebDriverException:對URL的遠程WebDriver服務器的HTTP請求在60秒後超時
我使用的是最新的Selenium,它是3.3.0,也是最新的Selenium支持,它也是3.3.0。
我已經設置了驅動程序:
public static class Driver
{
public static IWebDriver Instance { get; set; }
public static void Initialize()
{
Instance = new ChromeDriver();
}
public static void Close()
{
Instance.Close();
}
}
而且我運行一個基本的測試,以登錄到WordPress的賬戶,從一個不同的類,以保持從邏輯分離試驗:
[TestMethod]
public void Test_LogIn()
{
WordPressLoginPage.GoTo();
WordPressLoginPage.LoginAs("*******").WithPassword("*******").Login();
}
這裏是測試正在調用方法:
public class WordPressLoginPage
{
private const string LoginUrl = "https://wordpress.com/wp-login.php";
public static void GoTo()
{
Driver.Instance.Navigate().GoToUrl(LoginUrl);
var wait = new WebDriverWait(Driver.Instance, TimeSpan.FromSeconds(5));
wait.Until(d => d.SwitchTo().ActiveElement().GetAttribute("id") == ("user_login"));
}
public static LoginCommmand LoginAs(string userName)
{
return new LoginCommmand(userName);
}
}
public class LoginCommmand
{
private readonly string _userName;
private string _password;
public LoginCommmand(string userName)
{
_userName = userName;
}
public LoginCommmand WithPassword(string password)
{
_password = password;
return this;
}
public void Login()
{
var loginInput = Driver.Instance.FindElement(By.Id("user_login"));
loginInput.SendKeys(_userName);
var passwordInput = Driver.Instance.FindElement(By.Id("user_pass"));
passwordInput.SendKeys(_password);
var loginSubmit = Driver.Instance.FindElement(By.Id("wp-submit"));
loginSubmit.Submit();
var wait = new WebDriverWait(Driver.Instance, TimeSpan.FromSeconds(65));
wait.Until(d => d.SwitchTo().ActiveElement().GetAttribute("id") == ("search-component-1"));
}
}
例外告訴我,Timeo酒店這裏發生在這裏:
loginSubmit.Submit();
我可以看到,頁面仍然可能在我開始運行它兩分鐘後加載。
我已經看過其他問題在這裏關於相同的例外,但沒有任何答案似乎在這裏幫助。