As we discussed in the IDE section earlier, Selenium commands are the set of commands used to run our selenium tests.
We have a completely different set of commands in Selenium WebDriver for running various operations. Since we use Java with Selenium WebDriver, commands are simply Java-written methods.
We demand that you go through the Java OOPs (Object-Oriented Programming) concepts in the java programming language before going into the specifics of commands given by Selenium WebDriver. You can also refer to the definition portion of our Java OOPs given in the Java Tutorial.
We have produced our first test script in Selenium WebDriver so far, successfully. Thus one way to display WebDriver 's methods is to open the Eclipse IDE loaded with Selenium Webdriver jar archives, build a WebDriver driver object and click the dot key. It'll give you all of WebDriver 's potential methods.
In order to use any function of any type, we need to create a type property, and then all the public methods exist for the category.
A parameter is an argument that is passed on to a process to conduct a particular operation.
Methods will return a value or returning nothing (void). If the void is mentioned after the method, it means, the method is returning no value. If it returns a value, then the value form for e.g. getTitle): (string must be shown.
Now we are going to discuss the various commands WebDriver offers. Selenium WebDriver commands can be generally classified in the following categories.
There are two methods to fetch a web page:
The clear() method is used to clear the user inputs from the text box.
Often for some statements and testing we need to retrieve the text written over a web element. We use the method getText() to retrieve data written over some web element.
Drag and Drop operation is performed using the Action class.
WebElement element = driver.findElement(By.name("source")); WebElement target = driver.findElement(By.name("target")); (new Actions(driver)).dragAndDrop(element, target).perform();