繁体   English   中英

如何使用C#使用Selenium WebDriver知道URL?

[英]How to know a URL is existing using Selenium WebDriver using C#?

在我的应用程序中,我存储URL列表,仅存储具有现有URL的产品(即找不到任何404或Page或损坏的URL)。

我想在我的页面中查看,然后导航到该页面。 现在,我需要获取使用Selenium和C#中的WebDriver检查给定URL是否存在的代码。

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"));

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM