Saturday, June 20, 2015

Locating an element using the findElement method

By ID  : Locates an element the using ID attribute
Ex: driver.FindElement(By.Id("Value @ Id Attribute"))

By Name : Locates an element using the Name attribute
Ex: driver.FindElement(By.Name("Value @ Name Attribute"))

By class name : Locates an element using the Class attribute
Ex: driver.FindElement(By.ClassName("Value @ Class Attribute"))

By tag name : Locates an element using the tag name
Ex: driver.FindElement(By.TagName("HTML tag name"))

By link text : Locates link using it's text
Ex: driver.FindElement(By.LinkText("Value @ element"))

By partial link text : Locates link using it's partial text
Ex: driver.FindElement(By.PartialLinkText("Value @ element"))

By CSS : Locates element using the CSS selector
Ex: driver.FindElement(By.CssSelector("css selector"))

By XPathLocates element using XPath query
Ex: driver.FindElement(By.XPath("xpath query expression"))

0 comments