0% found this document useful (1 vote)
738 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)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (1 vote)
738 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)
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

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy