Latest Posts

Get Title, URL and Source Code of Webpage

import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; public class DemoClass3 { public static void main(String[] args) { // TODO Auto-generated method stub System.setProperty("webdriver.chrome.driver",C:\\Work\\chromedriver.exe"); WebDriver driver = new ChromeDriver(); driver.get("https://www.facebook.com"); System.out.println("Title of webpage is :" +driver.getTitle()); // we fetch title of webpage System.out.println("URL of webpage is : " +driver.getCurrentUrl()); // we fetch url of webpage System.out.println("Source Code of the page is : " +driver.getPageSource()); // fetching source code of webpage System.out.println("test case passed"); } }


No comments:

Post a comment