There are quite lot of methods in selenium, each of which are self explanatory. In this article we will see how to use most commonly used method of selenium.
The following are the methods,
1.getTitle
Returns the title of the webpage
2.getCurrentURL
Return the current URL of the opened webpage
3. getPageSource
Return the complete source code of the opened website.
Code
import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; public class Methods_of_selenium { public static void main(String[] args) { System.setProperty("webdriver.chrome.driver", "D:\\Software\\Selenium\\chromedriver_win32\\chromedriver.exe"); WebDriver driver = new ChromeDriver(); driver.get("https://google.co.in"); System.out.println(driver.getTitle()); System.out.println(driver.getCurrentUrl()); System.out.println(driver.getPageSource()); } }
Explanation
The above code contains all the three methods on it.