Selenium WebDriver

-Gulshan Nadaph

Why automate & how it works ?

 

Selenium is not installed it is configured.

Download selenium jar file and add it to project. Do it from here http://www.seleniumhq.org/download/

 

 

Locating Elements.

Identifies an element in the content of the web application

Locating an Element By ID: IDs are the safest and fastest locator option and should always be the first choice even when there are multiple choices

Eg : WebElement Ele = driver.findElement(By.id("toolbar"));

Locating an Element By Name:When there is no Id to use, the next worth seeing if the desired element has a name attribute.

Eg WebElement register= driver.findElement(By.name("register"));

Locating an Element By LinkText: make sure, there is only one unique link on the web page. If there are multiple links with the same link text,  in such cases Selenium will perform action on the first matching element with link.

Locating an Element By TagName: TagName can be used with Group elements like , Select and check-boxes / dropdowns.

eg .Select select = new Select(driver.findElement(By.tagName("select"))); select.selectByVisibleText("Nov");

Locating an Element By Class Name:
eg.WebElement classtest =driver.findElement(By.className(“sample”));

Firefox browser above version 48 can’t be used without geckodriver.The reason being Firefox webdriver is now shipped separately from the browser. And the calls are made through geckodriver instead of default firefox webdriver. You can find out how this development is going on here: Marionette. Without geckodriver you can’t execute firefox browser specific selenium code in any language.

deck

By Gulshan Nadaph