How to get HTML code of a WebElement in Selenium

时间:2023-03-09 06:45:42
How to get HTML code of a WebElement in Selenium

http://*.com/questions/32234205/how-to-get-html-code-of-a-webelement-in-selenium

WebElement wantele=findwebele.findElement(By.cssSelector("div.row.row-2.title"));

webElement.getAttribute("href");
webElement.getAttribute("class");
String s = we.getAttribute("outerHTML");
webElement.getAttribute("innerHTML");

WebElement wantele=findwebele.findElement(By.cssSelector("div.row.row-2.title"));
System.out.println("点击");
wantele=findwebele.findElement(By.cssSelector("a"));
//wantele.getAttribute("a[href]")
//wantele.click();
//Thread.sleep(5000);
System.out.println("url:"+wantele.getAttribute("href"));
//wantele.