Search On Google

Wednesday, February 13, 2019

Selenium commands and use

Comands with Explaination

driver.get("url")
//It automatically opens a new browser window and fetches the page that you specify inside its parentheses
driver.getTitle() //Fetches the title of the current page
getPageSource() //Returns the source code of the page as a String value
getCurrentUrl() //Fetches the string representing the current URL that the browser is looking at
getText()          //Fetches the inner text of the element that you specify

navigate().to() //It automatically opens a new browser window and fetches the page that you specify inside its parentheses.
navigate().refresh() //Refreshes the current page
navigate().back() //Takes you back by one page on the browser's history.
navigate().forward() //Takes you forward by one page on the browser's history
webdriver.close() //It closes only the browser window that WebDriver is currently controlling.
webdriver.quit() //It closes all windows that WebDriver has opened


To getting access on  elements in a Frameor popup, we should first direct WebDriver to focus on the frame or pop-up window first before we can access elements within them.

1. Focus ON Frame  or swithing frame example.
driver.switchTo().frame("classFrame");
driver.findElement(By.linkText("Deprecated")).click();

2.Focus on popup or swithing to popup example.
driver.switchTo().alert(); //swithing popup
driver.switchTo().alert().accept(); //closing popup 

No comments:

Post a Comment

About Me

My photo
Mumbai, Maharashtra, India