Types Of Webdriver Methods()

Selenium Element Locators, Inspecting Elements, Selenium WebDriver API Commands and Writing Selenium Test Cases.
Post Reply
sekhar
Posts: 42
Joined: Mon Dec 31, 2018 6:40 am

Types Of Webdriver Methods()

Post by sekhar » Sat Jan 05, 2019 7:21 am

How Many Types Of Webdriver Methods()?

chowdarybabu
Posts: 18
Joined: Thu Jan 03, 2019 3:52 am

Re: Types Of Webdriver Methods()

Post by chowdarybabu » Mon Jan 07, 2019 4:04 am

WEBDRIVER METHODS:
=====================
1. get ().
==>It is used to open specified url browser in windows.
Syntax: To launch the browser
Ex: driver. get(http://google.com);

2. getCurrentUrl().
==>Its Returns title of the Browser
Syntax: To launch the browser
Driver.get(http://google.com);
String url=driver.getCurrentUrl();
System.out.println(url);

3. getTitle().
==>It is used to get the title of current web page
Syntax: To launch the browser
driver.get(“http://www.google.com”);
String title=driver.getTitle();

4. getPageSource().
==>It is used to get the source of current load page
Syntax: To launch the browser
driver.get(“http://www.google.com”);
String pagesource=driver.getPageSource();
System.out.println(pagesource);

5. findElement().
==>It is used to find the first WebElement using the given method.
Syntax: To launch the browser
driver.get(“http://www.gmail.com”);
WebElement gmaillink=driver.findElement(By.id());
System.out.println(gmaillink.getText());

6. findElements().
==>It is used to find all elements within the current page
Syntax: To launch the browser
driver.get(“http://www.facebook.com”);
//To findelements
List links=driver.findElements(By.TagName(“a”));
//Counting no of links in result page
System.out.println(links.size());

7. close().
==>Close the current window, if there are multiple windows, it will close the current window which is active and quits the browser if it’s the last window opened currently.
Syntax: driver.get(“http://www.etestinghub.com”);
driver.close();

8. quit().
==>It is used to close every associated window which is opened.
Syntax: driver.get(“http://www.etestinghub.com”);
driver.quit();

9. getWindowHandle().
==>Whenever the web driver launches the browser it assigns the unique id to that browser which is called as window handler. This can be captured through the method.
Syntax: driver.getWindowhandle().

10. getWindowHandles().
==>Whenever multiple windows are opened by webdriver and we want to capture all their ids. We use this method.
Syntax: getWindowHandles().

11. switchTo().
==>Used to switch from one window to another window (or) window to a frame (or) frame to a window (or) window to an alert
Syntax:
driver.switchTo().window();
driver.switchTo().frame();
driver.switchTo().alert();

12. navigate().
==>The driver to access the browser’s history and to navigate to a given URL&Refresh page.
Syntax:
driver.get(“http://gmail.com”);
//navigate to page
driver.navigate().to(“http://estestinghub.com “);
//navigate to back
driver.navigate().back();
//navigate to forward
driver.navigate().forward();
//navigate to refresh page
driver.navigate().refresh();

13. manage().
==>This is used to perform maximize the size of the window.
driver.get(“http://gmail.com”);
driver.manage().window().maximize();

sekhar
Posts: 42
Joined: Mon Dec 31, 2018 6:40 am

Re: Types Of Webdriver Methods()

Post by sekhar » Mon Jan 07, 2019 4:10 am

What is the web operations?

srini
Posts: 76
Joined: Thu Jan 03, 2019 3:58 am

Re: Types Of Webdriver Methods()

Post by srini » Mon Jan 07, 2019 4:13 am

Web operations on web Elements:
=============================
1.click()
This is used to click on webelements like link, button, radio group, checkbox, images…etc.

2.sendKeys()
Purpose: This is used to sending inputs into text fields and text areas, and also used to select value from the drop-down box.

3.clear()
Purpose: This is used to clear the input from existing data.

4.getText()
Purpose: This is used to capture text of the webElement.

5. getTagName()
Purpose: This is used to capture HTML tag of the webElement.

6.getLocation()
This is used to capture X and Y co-ordinates of webelement in the application.

7.isSelected()
This is used to check, is the check-box is currently checked or unchecked to checked Radio buttons are selected or not.

8. isDisplayed()
This is a Boolean condition. It is used to either an element is visible or not.
If an element is displayed it gives true and an element is not displayed it gives false.

9. IsEnabled()
This is a Boolean condition. It is used to either an element is enable or not.
If an element is enable it gives true and an element is disable it gives false.

10.getAttribute ()
This is used to capture the attributes which are present in web applications.

Post Reply

Return to “Selenium WebDriver”