List of All Selenium WebDriver Commands with Examples

1. Browser Launch commands:

  • driver = new ChromeDriver();
  • driver = new FirefoxDriver();
  • driver = new EdgeDriver();
  • driver = new OperaDriver();
  • driver = new SafariDriver();

2. Navigation methods:

  • get(“http://www.seleniumlearn.com”);
  • navigate().to(“https://www.techlearn.in”);
  • navigate().back();
  • navigate().forward();
  • navigate().refresh();

3. Browser Close methods:

  • close();
  • quit();

4. Browser Maximize and Minimize methods:

  • manage().window().maximize();
  • manage().window().minimize ();

5. Identify the web elements methods:

  • findElement()

It used to find the one web element. It return only One WebElement type.

  • findElements()

It used to find more than one web element. It return List of WebElements.

6. Selenium Locators :

  • id()
  • name()
  • className()
  • cssSelector()
  • linkText()
  • partialLinkText()
  • tagName()
  • xpath()

7. Clear the contents of a textbox in selenium

    • Using clear() method.

driver.findElement(By.xpath(“xpath of box”)).clear();

8. Alternate way to click on login button

  • Use submit() method but it can be used only when attribute type=submit.

9. Selenium Drop Down Values:

  • selectByIndex()
  • selectByValue()
  • selectByVisibleText()
  • deselectAll()
  • deselectByIndex()
  • deselectByValue()
  • deselectByVisibleText()
  • getOptions()
  • getFirstSelectedOption()
  • getSelectedOptions()

10. Selenium iframes:

  • switchTo().frame(0);
  • switchTo().frame(1);
  • swicthTo().frame(2);