일부 C# Selenium WebDriver
테스트를 실행하고 있습니다. a) 사전에서 알려진 링크 텍스트 목록을 가져오고, b) 대상 웹 사이트에서 같은 목록을 가져온 다음 c) 비교를 수행합니다. 웹 페이지의 모든 내용을 예기치 않은/새로운/삭제 된 볼 수 있습니다.WebDriver C# - WebElement를 문자열로 변환
그러나 WebDriver
은 좋지 않습니다.
링크 텍스트와 링크를 나타내는 키/값 목록이 있습니다.
public static IDictionary<topNavigation, string> TabLinkURL
= new Dictionary<topNavigation, string>
{
{ topNavigation.News, "http://www.bbc.co.uk/news/" },
{ topNavigation.Sport, "http://www.bbc.co.uk/sport/" },
{ topNavigation.Weather, "http://www.bbc.co.uk/weather/" }
};
아래 코드에서 나는 웹 페이지로부터 링크를 얻는다.
var locateTheLinkSection = Driver.Instance.FindElement(By.XPath("//ul[@class='nav nav-tabs']"));
var actuaLinkSetCount = locateTheLinkSection.FindElements(By.TagName("a"));
List<string> actualLinkList = new List<string>();
foreach (var item in actuaLinkSetCount)
{
actualLinkList.Add(item.ToString());
}
Console.WriteLine("-----------------------------");
Console.WriteLine("The links-text set on the page is:");
int a = 1;
foreach (var link in actualLinkList)
{
Console.WriteLine($" {a}: {link}");
a++;
}
아이디어의 존재는 내가 다시 웹 페이지에서 제공되는 링크에 대한 (위의 사전에있는 값에서) 알려진 링크 위치를 비교할 수 있습니다. 그러나 반환됩니다 모든는 다음과 같습니다
The links-text set on the page are:
1: OpenQA.Selenium.Firefox.FirefoxWebElement
2: OpenQA.Selenium.Firefox.FirefoxWebElement
사람이 비교 방법 또는 문자열로 위를 변환하는 그것을 반환 할 문자열로 링크 텍스트를 캡처하는 중 알고 있나요
?감사합니다.
마크.