Mindmajix

Selenium WebDriver Commands List

Selenium WebDriver Commands

We will look in detail for each of the Selenium webdriver commands that we have.

Browser initiation:

WebDriver driver=new FirefoxDriver();

WebDriver driver=new SafariDriver();

WebDriver driver=new chromeDriver();

WebDriver driver=new InternetExplorerDriver();

  • Open URL:

driver.get(“http://www.google.com”);

  • Click a link,Check box,Radio button, button:

driver.findElement(By.id(“gbqfq”)).click();

  • Clear the text field:

driver.findElement(By.id(“abc”)).clear();

  • Type in Text box or Text Area:

driver.findElement(By.name (“username”)).sendKeys(“test”);

Select a Value from Dropdown:

Select select = new Select(driver.findElement(By.tagName(“select”)));
select.selectByVisibleText(“Apple”);

Switch to window:

driver.switchTo().window(“windowName”);

Switch to Frame:

driver.switchTo().frame(“frameName”);

Switch to Alert:

driver.switchTo().alert().accept();

Confirmation Box:

driver.switchTo().alert().accept();
driver.switchTo().alert().dismiss();

Navigate Forward:

driver.navigate().forward();

Navigate Backward:

driver.navigate().back();

Using Actions Class

Drag and Drop

WebElement source = driverdriver.findElement(By.name(“source”));
WebElement target = driver.findElement(By.name(“target”));
(new Actions(driver)).dragAndDrop(source, target).perform();

Mouse Hover:

Actions builder = new Actions(driver);
WebElementtagElement = driver.findElement(By.id(“someid”));
builder.moveToElement(tagElement).build().perform();


0 Responses on Selenium WebDriver Commands List"

Leave a Message

Your email address will not be published. Required fields are marked *

Copy Rights Reserved © Mindmajix.com All rights reserved. Disclaimer.
Course Adviser

Fill your details, course adviser will reach you.