Automation QA Testing Course Content

WebDriver Browser Commands


browser methods:

WebDriver driver=new FirefoxDriver();
1)get("url"):it opens the given url in the browser
//usage in the testscripts
//open the url
driver.get("url");
Most common way of loading a URL in browser in Selenium is using get() method.

Syntax:  void get(java.lang.String url)

Points to know about get():

get() method is declared in WebDriver interface.
get() method is defined in RemoteWebDriver class.
get() method returns void.
You can not go back and forward using get() method. 
You can use get() multiple times in a                  program.
2)getTitle():it fetches the current page title,it returns a string type data
//datatypeofmethod variablename=objref.returnnostaticmethod();
String t=driver.getTitle();
SOP(t);//it prints the value of variable into console

3)getCurrentUrl():it fetches the current page absolute url,it returns a string type data
String absurl=driver.getCurrentUrl();

4)getPageSource():it fetches the current page html source code,it returns a string type data
String src=driver.getPageSource();

5)getWindowHandle():it returns current window id,it returns a string type data
String pid=driver.getWindowHandle();

6)getWindowHandles():it fetches all open window ids into set type collection

//collectiontype<datatype>collectionname=webdrivermethods(plural);
Set<String>handles=driver.getWindowHandles();

7)close():it closes the current window

driver.close();

8)quit():it closes all the associated windows
driver.quit();

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.