Selinium Webdriver Scripts
Selinium Webdriver Scripts
Selinium Webdriver Scripts
http://funandknowledge.blogspot.in/
Selenium Webdriver Scripts 1. get( ) - Selenium WebDriver method to open the specified URL page public class Sample { public static void main(String[] args) { WebDriver driver = new FirefoxDriver(); driver.get("http://www.funandknowledge.blogspot.com"); } } Opens google page 2.getTitle() - Returns The title of the current page public class Sample { { public static void main(String[] args) WebDriver driver = new FirefoxDriver(); driver.get("http://www.funandknowledge.blogspot.com"); System.out.println(driver.getTitle()); } } Output- QTP Scripts and Selenium Webdriver Scripts
For more Selenium Webdriver Scripts Visit - http://funandknowledge.blogspot.in/
3. getCurrentUrl() - Returns The URL of the page currently loaded in the browser public class Sample { { public static void main(String[] args) WebDriver driver = new FirefoxDriver(); driver.get("http://www.funandknowledge.blogspot.com"); System.out.println(driver.getCurrentUrl()); } }
Output - http://www.funandknowledge.blogspot.in/ 4. getPageSource() - Returns the source code of the page public static void main(String[] args) { WebDriver driver = new FirefoxDriver(); driver.get("http://www.google.com"); System.out.println(driver.getPageSource()); } }
public class Sample { { public static void main(String[] args) WebDriver driver = new FirefoxDriver(); driver.get("http://www.funandknowledge.blogspot.com"); driver.close(); } }
6.How to Maximize browser window in Selenium Web Driver public class Sample { public static void main(String[] args) { WebDriver driver = new FirefoxDriver(); driver.get("http://www.funandknowledge.blogspot.com"); driver.manage().window().maximize(); } }
public class Sample { public static void main(String[] args) { WebDriver driver = new FirefoxDriver(); driver.get("http://google.com"); System.out.println(driver.findElement(By.name("btnK")).g etText()); }