在我的应用程序中,我存储一个URL列表,仅存储具有现有URL(即找不到任何404或Page或URL损坏)的产品。
我想在我的页面中查看,然后导航到该页面。现在,我需要获取使用Selenium和C#中的WebDriver检查给定URL是否存在的代码。
答案 0 :(得分:0)
string urlFraction = "/myfolder/some.html";
double seconds = 10;
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(seconds));
bool wellTheAddressBarChanged = wait.Until(ExpectedConditions.UrlContains(urlFraction));
// TODO: Give IE11 special treatment here.
bool thePageActuallyLoaded = wait.Until(d => ((IJavaScriptExecutor)d).ExecuteScript("return document.readyState").Equals("complete"));