Selenium Webdriver Commands
There are many selenium webdriver commands use to automate a project as we have seen in my previous posts of selenium webdriver. Some of the available commands in webdriver are Browser Commands, Interactive Commands, Information Commands, String Comparison Commands, Validation Commands etc.
The browser commands use to open the browser, close the browser and open the website by get the url.
get :- It is to open the URL of the web application.
quit():- It is to close the browser.
close:- It is to close the child or pop up window.
The interactive commands use to interact with the web application like, enter values in the textbox, clear the values from the text box, click any button, check box or radio button, select the values from the dropdown.
sendkeys:- It is to enter some value in the text box.
Syntax: driver. findelement (By.name (“username”)). sendkeys(“name1”);
clear:- It is to clear the data from the text box.
Syntax: driver. findelement (By.name (“username”)). clear();
click:- By using this command we can clink on a button, radio button, checkbox, image and link.
Syntax: driver. findelement (By.name (“button1”)). click();
newSelect:- It is to select a value from a dropdown and a list box.
Syntax: new Select(driver.findElement(By.id(“continents”))).selectByVisibleText(“Australia”);
The information commands use to extract the information within the tags, outside the tags or dropdowns etc. from the applications.
getText():- It is to take the information from the application which is available outside of the tags.
getAttribute():- It is to take the information from the application which is available in between the tags.
getOptions():-It is to take the information from the application which is available within a dropdown and a list box.
String Comparison Commands:
We can compare the strings with another string by using the below commands.
equals:- It is to compare the string with another object where it is case sensitive.
equalsIgnoreCase:- It is also to compare with another string but it is not case sensitive.
Contains:- It is to check that whether the sequence of characters are available in string or not.
The validation commands use to validate the element availability, enable, disable and select the check boxes etc.
isDisplayed():- It is to check whether the element is available or not.
isEnabled():- It is to check whether the element is enabled or disabled.
isSelected():- It is to validate whether the radio button or check box is selected or not.