如何使用带有Java的Selenium WebDriver查看“标题”和“元”标签之间的页面来源?
You can try driver.getPageSource()
after you have loaded the page.
You can compare the Title of a page as below code:
String actualTitle = driver.getTitle();
String expectedTitle = "My Title";
assertEquals(actualTitle, expectedTitle);
If you want to get page source you can get by using the following java code:
String pageSource = driver.getPageSource();
If you want to verify a particular text is present or not on the page, do as below:
boolean isTheTextPresent = driver.getPageSource().contains("your text");
assertTrue(isTheTextPresent);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.