Getting ALL attributes from an IWebElement with Selenium WebDriver

后端 未结 6 849
半阙折子戏
半阙折子戏 2020-12-10 16:18

I want to extract some information from the DOM with Selenium. I\'m using the C# WebDriver.

Looking at the IWebElement interface you can easily extract a given attri

6条回答
  •  北荒
    北荒 (楼主)
    2020-12-10 17:11

    You can try this:

    IWebElement element = driver.FindElement(By.Id("myButton"));
    
    string elementHtml = element.GetAttribute("outerHTML");
    

    This will give you the html of the element. From here, you can parse it, as Arran suggested

提交回复
热议问题