How to get HTML code of a WebElement in Selenium

后端 未结 6 1049
离开以前
离开以前 2020-12-18 17:44

I am new at testing so my apologies in advance if my question sounds a bit primary.

I am using Selenium and Java to write a test.

I know that webElem

6条回答
  •  春和景丽
    2020-12-18 18:43

    webElement.getAttribute("href");
    webElement.getAttribute("class");
    .
    .
    .
    

    or to get them all:

    Object[] attr = ((JavascriptExecutor)seleniumdriver).executeScript("return arguments[0].attributes);", webElement);
    

提交回复
热议问题