0% found this document useful (1 vote)
744 views

Selinium Webdriver Scripts

The document provides examples of Selenium WebDriver scripts for common tasks like opening a URL, getting the page title and URL, getting page source, closing the browser window, maximizing the browser window, and getting label text. It demonstrates how to use various Selenium WebDriver methods like get(), getTitle(), getCurrentUrl(), getPageSource(), close(), manage().window().maximize(), and findElement().getText(). The document recommends visiting http://funandknowledge.blogspot.in/ for more Selenium WebDriver scripts.

Uploaded by

seleniumuser123
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (1 vote)
744 views

Selinium Webdriver Scripts

The document provides examples of Selenium WebDriver scripts for common tasks like opening a URL, getting the page title and URL, getting page source, closing the browser window, maximizing the browser window, and getting label text. It demonstrates how to use various Selenium WebDriver methods like get(), getTitle(), getCurrentUrl(), getPageSource(), close(), manage().window().maximize(), and findElement().getText(). The document recommends visiting http://funandknowledge.blogspot.in/ for more Selenium WebDriver scripts.

Uploaded by

seleniumuser123
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Selenium Webdriver Scripts

http://funandknowledge.blogspot.in/

For more Selenium Webdriver Scripts Visit - 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()); } }

For more Selenium Webdriver Scripts Visit - http://funandknowledge.blogspot.in/

5. close() - Closes the current window

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(); } }

For more Selenium Webdriver Scripts Visit - http://funandknowledge.blogspot.in/

7. How to get label text or capture label text in Selenium webdriver

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()); }

Output- Google Search

For more Selenium Webdriver Scripts Visit - http://funandknowledge.blogspot.in/

You might also like